[wg-camlp4] Against the use of syntactically-valid OCaml code for syntax extension purposes
Alain Frisch
alain at frisch.fr
Wed Jan 30 09:23:57 GMT 2013
On 01/30/2013 09:36 AM, Leo White wrote:
> 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.
The risk is that the user writes {@ foo} instead of {@ foo}. This does
not sound much less probable than the user writing {@ foox} instead of
{: foo}. But I will not fight against non-ignorable attributes!
> For instance, "foo bar {: ... }" means that foo will be called with bar
> and whatever that attribute becomes as arguments.
This was not my understanding. You seem to imply that {: ... } here is
not really a (postfix) attribute on the expression "foo bar", but that
it is a stand-alone expression. So actually, it is not attached on
anything, it is not an attribute. I'd rather write it:
foo bar ((@marker) e)
where the @marker attribute is to be detected by the "expander" and e is
its argument. If we want to make it clear that "e" will be interpreted
in a non-trivial way and that (@marker) must be treated (and otherwise
the type-checker should complain by mentioning it explicitly), we could
write:
foo bar ((:marker) e)
(Assuming now that (:...) is in prefix position.)
Alain
More information about the wg-camlp4
mailing list