[wg-camlp4] Request for feedback

Leo White lpw25 at cam.ac.uk
Thu Mar 14 17:18:56 GMT 2013


> [...] I appreciate the idea of having a single,
> uniform way to put an annotation in any grammar class, that can be
> introduced anywhere the keyword structure is not satisfying.

I agree.

> That said, I'm still a bit uncomfortable with translating (let%foo p =
> e1 in e2) into [%foo let p = e1 in e2]. This amounts to injecting
> arbitrary "Annot" node in the AST structure, and I'm worried about the
> implementation consequences: the -bin-annot implementation showed than
> adding new nodes in between is a bad idea when the compiler does
> depth-higher-than-one pattern-matching to spot optimization
> opportunities. 

Since the extension nodes have to be compiled away by an AST transformer
before type-checking, there is no danger of them preventing an
optimisation. Attributes on the other hand could cause problems.

> I'm wondering whether all such extensibility data could
> have a more second-class place in the AST structure, as the location
> fields have today

I think that this is definitely the right way to go for attributes. For
extensions, I think it makes more sense to give them their own AST
node. The idea is that an extension used as an expression *is* an
expression, so it should be represented in the AST as such.


More information about the wg-camlp4 mailing list