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

Alain Frisch alain.frisch at lexifi.com
Mon Mar 4 20:43:08 GMT 2013


On 3/4/2013 8:09 PM, Leo White wrote:
>> Extensions on the same categories:
>>
>>   [#lid expr]
>>
>
> This delimiter isn't technically safe (it could be made safe but its
> probably not worth the effort), might I suggest [%lid expr] as an
> alternative.

Ah, I keep forgetting about #type pattern...  I'm fine with [%lid expr].

> How about including "Item" extensions "[%%lid expr]"? I would rather not
> force people to use "include [%id expr]". I can imagine syntax
> extensions that might want to be used as both a strucuture item and a
> module expression.

Well, the extension could always use a different lid to distinguish the 
two cases, but ok, it doesn't add too much complexity to support "item" 
extensions directly.


>>  type t =
>>    | A [@id expr] [@id expr]
>>    | B [@id expr] [@id expr] of ...
>
> I agree that we need a special syntax for variant constructor
> attributes. How about:
>
> type t =
>   | A with id, id(expr)
>   | B of ... with id(expr), id

This is a case where the standard syntax for attributes works well (if 
we put attributes before constructor arguments).  What's the argument in 
favor of a dedicated syntax?  (I like the fact that all attribute 
syntaxes look similar.)

> We could also allow this for convenient record label attributes.

Yes, it make sense.

> I think
> this syntax is already used in type-conv, it fits in with the "with"
> attributes for type declarations, and is a lighter syntax than the
> alternative.

What do you call lighter?  It uses fewer non-alphanumeric symbols, but 
it becomes more compact only with 4 attributes:

A with id(expr), id(expr), id(expr), id(expr)
A [@id expr] [@id expr] [@id expr] [@id expr]


How does type-conv distinguish attributes on the last constructors from 
attributes on the type itself?  (Where do we find the documentation for 
the syntax recognized by type-conv?)


Alain


More information about the wg-camlp4 mailing list