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

Alain Frisch alain.frisch at lexifi.com
Mon Mar 4 10:47:48 GMT 2013


On 03/01/2013 06:52 PM, Leo White wrote:
> Looking at the code, I don't think that it is taking the correct
> approach to defining the extension syntaxes.

I'll backtrack my changes (I agree with Gabriel that it is not a great 
idea to "split" declarations of multiple types into individual 
signature/structure items), and try to incorporate yours.

However:

> 3. With Attributes
>
>      with ident ( expr), ident, ident (expr)
>    Attached postfix to structure items or signature items.

I think those attributes should be attached to declared types, not 
structure/signature items.  It is important to attach different 
attributes to each type in a multi-type declaration.

What I'm less convinced now is that we need attributes on arbitrary 
structure/signature items, rather that on individual components. 
Consider for instance signature items:

and signature_item_desc =
     Psig_value of string loc * value_description
   | Psig_type of (string loc * type_declaration) list
   | Psig_exception of string loc * exception_declaration
   | Psig_module of string loc * module_type
   | Psig_recmodule of (string loc * module_type) list
   | Psig_modtype of string loc * modtype_declaration
   | Psig_open of Longident.t loc
   | Psig_include of module_type
   | Psig_class of class_description list
   | Psig_class_type of class_type_declaration list


I propose to add attributes to value_description, type_declaration, 
exception_declaration, the Psig_module case each item in the 
Psig_recmodule case, the Psig_modtype case, the Psig_open case, the 
Psig_include case, class_description, class_type_declaration.  While we 
are at it, we could introduce a proper record types for 
exception_declaration.  We could also push the names (of declared 
values, names, etc) inside their *_description or *_declaration record.


Opinion on these changes?   I think it's rather important to agree on 
where attributes can be put exactly.



Alain


More information about the wg-camlp4 mailing list