[wg-camlp4] My uses of syntax extension

Leo White lpw25 at cam.ac.uk
Tue Jan 29 15:47:48 GMT 2013


>On 29 January 2013 14:47, Leo White <lpw25 at cam.ac.uk> wrote:
>> As far as I'm concerned <:expr < 3 + 4 >> is simply a syntactic short 
>> hand for something like AstPlus(AstConstInt 3, AstConstInt 4).
>
>Yes.  That's exactly why quotations belong in programs that process
>ASTs (e.g. in compilers or metaprograms), not in programs that only
>process the result of evaluating ASTs (i.e. in user code).  User code
>doesn't typically deal with AstPlus and AstConstInt, but it might well
>need to add numbers.

But user code does deal with the results of other quotations, like HTML and 
SQL quotations. I don't see a real difference between using a quotation to 
define some constructors representing HTML and using a quotation to define 
a function. Just because the function will at some point get called.

I think this all comes from the confluence of the word quotation as in a 
string quotation (e.g. "a string"), which is something that must be lexed 
separately from the rest of the language, and the use of ' (or "quote") in 
lisp to delay evaluation. MetaOCaml's quotations are an example of this 
second type.

You want to reserve the camlp4 quotation syntax for use as the second kind 
of quotation. However, both the camlp4 tutorial 
(http://caml.inria.fr/pub/docs/tutorial-camlp4/tutorial004.html) and many 
of the common uses of camlp4 quotations treat them as the first kind.



More information about the wg-camlp4 mailing list