[wg-camlp4] Against the use of syntactically-valid OCaml code for syntax extension purposes
Alain Frisch
alain at frisch.fr
Wed Jan 30 08:33:02 GMT 2013
On 01/30/2013 07:31 AM, Gabriel Scherer wrote:
> My understanding is that this is precisely what type-conv does:
> annotate the type declaration itself, rather than the type expression
> or the whole phrase.
I agree it make sense to allow attaching attributes to various syntactic
constructions, including those which are not "algebra", and type
declaration are a good candidate for that. Note that when I proposed
attributes, I wrote:
> I propose to start discussing the addition of attributes to most syntactic categories (expressions, type expressions, patterns, type declarations, module expressions, structure/signature items, etc).
I'm not sure we need to allow attributes on specific parts of expression
kinds (e.g. annotate the "for" itself, or each binding in a "let"). I'm
not fundamentally opposed to it, but it will add a lot of complexity to
the Parsetree with no obvious benefit. This probably needs to be
discussed on a case-by-case basis.
> Finally, using a
> convention to annotate the pattern may give rise to critical pairs /
> ambiguities where the semantics of the program depends of whether we
> consider the annotation to cover the pattern or the declaration (for
> annotations that make sense in both, eg. @profile).
Yes, but it does not seem difficult to have a different convention for
something related to the pattern itself and something related to the
binding, if the same general notion need to apply to both.
Alain
More information about the wg-camlp4
mailing list