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

Alain Frisch alain.frisch at lexifi.com
Wed Mar 6 16:41:32 GMT 2013


On 03/06/2013 05:31 PM, Xavier Clerc wrote:
> I just feel dizzy when there is less type safety...

But is it really the case that there is less safety?  If you use a 
"wrong" expression as an argument of some attribute, the -ppx rewriter 
will (hopefully) let you know at compile time, exactly as a good old 
type error.  I see there is something "weird" in re-using the same 
syntax as expressions for something treated very differently by the 
compiler, but I believe the technical advantages outweigh this feeling 
of weirdness.

The only thing which is not checked is the fact that the attribute 
itself is recognized (i.e. if you mistype the attribute name, the 
attribute will just be ignored by the type-checker).  We could introduce 
yet another syntax for non-ignorable attributes.  Or we could create an 
"attribute checker" (a -ppx rewriter applied after all the other ones, 
and which checks that no attribute remain in the AST).  But since it is 
not an abnormal situation to have attributes remaining in the final AST 
(for later use by tools based on .cmt/.cmti files, for instance, such as 
a new ocamldoc), the tool would need to be configured with a list of 
such attributes to accept.


Alain


More information about the wg-camlp4 mailing list