Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] global record
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nicolas Pouillard <nicolas.pouillard@i...>
Subject: Re: On language extensions (was Re: [Caml-list] global record)
On 7/19/06, Daniel Bünzli <daniel.buenzli@epfl.ch> wrote:
> Hello,
>
> I would like to issue a warning about everybody rolling its own
> syntax extension to suit its taste.
>
> Contrary to lisp's macros, each syntax extension is syntactically a
> new language. Hence not only do we need to learn a new semantics but
> also a new syntax. If I have to read someone else's code I want to
> read caml code and not caml code augmented with the author's
> syntactic obsessions.
>
> In code readability, there is a trade-off between succinctness and
> syntactic regularity. Camlp4 extensions increase the former but
> decrease the latter. For me camlp4's usage should be limited to real
> domain specific languages (e.g. like coq does) and research, it
> should not be used to increase ocaml's succinctness.
>

[...]

Camlp4 is "just" a pre-processor, you always can unsugar your code and
take back a plain ocaml code. This can be done to get rid of a no more
maintained extension, or to understand some code that use such an
extension.

$ camlp4o pa_foo.cmo pa_bar.cmo pr_o.cmo input.ml -o output.ml

You can now read output.ml as a plain ocaml file.

Thus, IMHO, people can add syntax extensions since we have an easy way
to get rid of them.

-- 
Nicolas Pouillard