[wg-camlp4] A new branch to experiment with extension points

Alain Frisch alain.frisch at lexifi.com
Thu Mar 7 09:07:41 GMT 2013


On 03/06/2013 04:51 PM, Alain Frisch wrote:
> Do people see use cases where the prefix syntax is much better?

I found only one case: attaching meta-data to a function in an .ml file 
is better done before the function code than after, for readability 
purposes.  (In interfaces, it's fine to put the comments/meta-data after 
the function declaration, since the prototype is short enough.)


[^^backend ensure_inlining]
let foobar x l =
   ...

But I'm not sure it is worth creating more syntax only for that case.

What do you think?

Unless someone objects to it, I'll remove the prefix syntax.



An alternative solution to the case above (which we can implement later) 
could be to keep the standard syntax for postfix [@...] attributes and 
allow to put the attribute on the function name and/or on the let keyword:

    let foobar [@backend ensure_inlining] x l =
       ...

    or:

    let[@backend ensure_inlining] foobar x l =
       ...

which could be represented as:

    let foobar = ((fun x l -> ...) [@backend ensure_inlining])
    (the attribute is on the function expression)

    or:

    let (foobar [@backend ensure_inlining]) = fun x l -> ...
    (the attribute is on the pattern)




Alain


More information about the wg-camlp4 mailing list