[wg-camlp4] [Caml-devel] Structure/signature attributes suggestion

Alain Frisch alain at frisch.fr
Tue Apr 15 12:44:04 BST 2014


On 04/15/2014 11:48 AM, Drup wrote:
> I agree, but the added verbosity with all those additional brackets
> bother me even more, especially for attributes. I wonder if we could
> drop some brackets when there is no added expression : "x at foo" instead
> of "x[@foo]" .

Since @ is a binary operator, x at foo would not be available for 
expressions. I don't think it is worth supporting it for other kinds of 
syntactic categories.

>
> Also, to follow some shortcuts with extension nodes on keyword, would it
> be possible to add those syntax :
>
> 1) "let%foo x = 3" => "[%%foo let x = 3]"
> Since "let ... " is not an expression (but a toplevel declaration), the
> %foo doesn't work on them.
> We could use %% for consistency, but the added symbol doesn't bring any
> added value, since the % character is already specific enough.

Good idea.  I've committed it to trunk, rev 14600.  Here we benefit from 
the fact that the payload of extension nodes can be arbitrary 
structures, not just expressions.

(Attributes are still not supported on let-binding structure items: 
let[@foo] x = 3.)

> 2) "( ... )%foo"
> It would be equivalent to "begin%foo ... end" or [%foo ... ] but (imho)
> easier on the eyes and closer to a natural ocaml syntax, even it  it's
> not much shorter, character wise.

Same as above: (%) is a valid infix operator.


-- Alain


More information about the wg-camlp4 mailing list