[wg-camlp4] My uses of syntax extension
Jeremy Yallop
yallop at gmail.com
Tue Jan 29 15:27:31 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.
> My point about functions was that you seemed to be defining "using" as
> executing, which is obviously only possible for a quotation that represents
> OCaml functions.
Actuially, that's not what I mean by "using". Evaluating is indeed a
form of using, but evaluating function syntax creates a function
value; it doesn't call the function. Quoting prevents evaluation for
functions, just as for everything else, so when you quote function
syntax you get some kind of code representation rather than a function
value. There's really nothing special about functions here.
More information about the wg-camlp4
mailing list