[wg-camlp4] A new branch to experiment with extension points
Xavier Clerc
xavier.clerc at inria.fr
Wed Mar 6 19:24:25 GMT 2013
----- Mail original -----
> 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.
Quite not, as this is rewriter-dependent. A developer may very well
decide to accept both integers and floats for a given value for example.
(...)
> 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).
Yes, this is a potential pitfall.
And I would state things differently: the only thing that is checked
is that attribute values are syntactically well-formed.
> 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.
Rather than a new syntax (they are already multiple), I would argue
for another solution:
- maybe a tag to indicate that a given attribute has been preprocessed;
- or, as the rewriter to register the attributes they handle and issue
a warning if there is an attribute that cannot be treated by the
rewriters.
Just wild ideas, though.
Xavier Clerc
More information about the wg-camlp4
mailing list