[wg-camlp4] Pending issues

Leo White lpw25 at cam.ac.uk
Wed Feb 13 13:47:27 GMT 2013

>I understand the need for accessing annotation at runtime, but why
>whould anyone reasonnable want something else than simple declarative
>informations, for which a simple substet is enouth.

People will want them for statically handled attributes. You could restrict 
the kind that was passed to the run-time but that inconsistency will 
probably annoy people.

> And restricting
>as much as possible this make the usage far easier: this kind of value
>won't be manipulated by 'experts' writing syntax extensions, but by
>classical users. 

For the kind of information most classical users would want to get from an 
attribute, simple functions like "Ast.getIdent" and "Ast.getIntConst" are 
even easier to use than a reduced AST.

>Moreover, if the ast you are manipulating is the full
>ocaml one, it will be impossible to write exhaustive pattern matching
>without breaking at each new ocaml release.

When fetching data from an attribute you probably don't want exhaustive 
pattern matching. If you expect people to attach a number or a string to a 
type then all you want is to check if the attribute is a number or a 
string, and if it isn't then ignore it or raise an exception. You are 
unlikely to want to perform a different action for each possible kind of 

The exception to this would be if you wanted to handle general expressions 
within an attribute, but in that case you probably want to handle all 
expressions not a restricted subset.

More information about the wg-camlp4 mailing list