[wg-camlp4] My uses of syntax extension

Leo White lpw25 at cam.ac.uk
Tue Jan 29 14:17:33 GMT 2013

>In each case above, omitting the quotation delimiters would cause
>immediate evaluation of the quoted code.  The reason for quoting is to
>prevent evaluation and make the code available as a value instead.

I think this a pretty dubious claim for both the camlp4 quotation and the 
string. In both cases those are simply extra syntax for representing 
values. For instance I could replace the camlp4 quotation with ordinary 
OCaml constructors. They do not delay execution because they are never 

>Now consider the arrow notation example:
>      let g = <:proc< x -> y <- f -< x + 1;
>                           return -< y + 2 >>
>Here the aim is quite different: we don't want to prevent immediate
>evaluation; instead, we want to transform the syntax *for* immediate
>evaluation.  We don't want g to be bound to some user-manipulable
>representation of the code.  Instead, we want the *implementation* to
>consume the desugared notation, type check it and bind the result of
>evaluating it to g.

You are making an arbitrary distinction between functions and other values.

let g x = <:proc< x -> y <- f -< x + 1;
                       return -< y + 2 >>

provides a value (in this case a function) to be used by the program just 

let blah = <:expr < let f = foo >>

provides a value to be used by the program.

More information about the wg-camlp4 mailing list