[wg-camlp4] Request for feedback

Gabriel Scherer gabriel.scherer at gmail.com
Thu Mar 14 16:57:27 GMT 2013


> What do other people on the list think?
>
>  - Should we support a compact syntax for extension nodes on all
> constructions starting with a keyword or delimiter (and if so, should this
> become the only syntax for extension nodes)?
>
>  - If not, should be do it for the (local) let-binding only?  Or, if we
> special-case this construction, should we do something different for it
> altogether (arbitrary symbol characters)?

If we have a let%foo syntax, I think it's better to have it for all
constructions starting with a keyword than for an arbitrary subset of
them. I have no strong opinion on whether delimiters should be
included as well. That said, 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.

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. 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 (they're attached to each "real AST node", not a
node of their own), orthogonally to the distinction (to which I'm not
really attached in any case) between "stuff that it is legal to have
left after preprocessing and must be ignored" and "stuff that should
provoke a failure if left unattended".

On Thu, Mar 14, 2013 at 12:34 PM, Alain Frisch <alain.frisch at lexifi.com> wrote:
> On 03/14/2013 12:00 PM, Leo White wrote:
>>
>> To be honest I am (cautiously) ok with "let%lwt x = ...".
>
>
> If we only support the special form for "let", I agree it would make sense
> to make "let%ext" a single token.
>
> I don't have a strong opinion about it, but if we special-case the treatment
> of the "let" binding, maybe it is worth introducing a custom kind of
> extension point for this construction, like supporting an arbitrary sequence
> of symbol characters:
>
>   [%%lwt let suffix = "**"]
>   [%%lazy let suffix = "..."]
>
>   ...
>      let** x1 = e1 in
>      let** x2 = e2 in
>      ...
>   ...
>      let... rec x = button "X" ~click:(fun () -> y # set_text "X")
>      and  y = button "Y" ~click:(fun () -> x # set_text "Y")
>      in
>      hbox [x; y]
>
>
>
>> Note that for "let" the trade-off is potentially much worse:
>
>
> It makes sense.
>
> What do other people on the list think?
>
>  - Should we support a compact syntax for extension nodes on all
> constructions starting with a keyword or delimiter (and if so, should this
> become the only syntax for extension nodes)?
>
>  - If not, should be do it for the (local) let-binding only?  Or, if we
> special-case this construction, should we do something different for it
> altogether (arbitrary symbol characters)?
>
>
>
> Alain


More information about the wg-camlp4 mailing list