[wg-camlp4] Against the use of syntactically-valid OCaml code for syntax extension purposes

Leo White lpw25 at cam.ac.uk
Wed Jan 30 08:36:47 GMT 2013


>What makes sense is maybe to distinguish attributes which can be dropped 
>silently by the compiler (but used by other tools like ocamldoc, for 
>instance) and those on which the type-checker needs to fail.  This is 
>not strictly necessary if we already have a new kind of expressions on 
>which the type-checkers fail, and it does not really bring much security 
>because the user could easily use the other syntax of attributes and get 
>(probably) simply a type error instead of a "remaining attribute" error.

An extension could only support {: foo } style attributes (the ones that 
the type-checker fails on), so then there would be no risk of a typo or 
missed ppx option causing a silent fail or an unhelpful error message.

I also think that it will make it easy to read code: If you see {: ... } 
then that will be translated into an expression/patter/..., if you see {% 
... } then you know that the expression it is attached to will be 
translated.

For instance, "foo bar {: ... }" means that foo will be called with bar and 
whatever that attribute becomes as arguments. "foo bar {% ... }" means that 
foo and bar are going to be translated in some way.

And since we're probably supporting <: ... >, I see no harm in supporting 
<% ... > as well, especially if we support {: ... } and {% ... } (or (: ... 
) and (% ... ) if you prefer).



More information about the wg-camlp4 mailing list