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: Daniel_Bünzli <daniel.buenzli@e...>
Subject: On language extensions (was Re: [Caml-list] global record)
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.

This may be seen as a matter of personal taste: it is true that I  
lean towards syntactic regularity, i.e. less syntactic constructs.  
However there is another argument against using extensions: code  
maintenance. You have no guarantee that (1) an extension will not be  
broken by the next version of the language and (2) that the author  
will continue to maintain it.

And by the way, are we guaranteed that two arbitrary camlp4  
extensions will compose or may the order of application matter ?

Cheers,

Daniel

P.S. Even for domain specific languages many things can be done in  
pure ocaml by embedding the dsl in ocaml using meta-programming  
techniques.