[wg-camlp4] Negative field report: extension points unsuited for (matches p when e)

Leo White lpw25 at cam.ac.uk
Sat May 4 14:27:31 BST 2013


> As a side note, I've recently changed the syntactic category accepted as arguments of attributes/extensions from
> expressions to structures, which are strictly more general (an expression is also syntactically a valid structure item,
> and thus a structure, in itself).

I've been going through the uses of camlp4 in opam and recording how
each of their syntaxes could be adjusted to fit ppx. (I've been doing it
on and off for a few weeks, and am about half-way through them). One
group of extensions that would currently need quotations are those that
create types from other types. For example, the following quotation from
shcaml:

  <| seq: Line.present; source: Line.present >

this quotation is supposed to be a type expression, where the body of
the quotation is essentially an object type.

For cases like these, I thought it would be a good idea to change from
having expressions as bodies, to having the bodies be like a
simple type constraint:

  [%id expr : core_type]

where both the expression and the "constraint" are optional. This would
allow the example above to be represented as:

  [%line: < seq: Line.present; source: Line.present >]

Do you think that we could support this form as well as structures? If
not, did you have any specific cases that you wanted to use structures
for? I could imagine structures being useful for top-level extensions,
maybe we could have:

  [%%id struture]

and

  [%id expr : core_type]


More information about the wg-camlp4 mailing list