[wg-camlp4] Pending issues

Pierre Chambart pierre.chambart at ocamlpro.com
Wed Feb 13 12:15:41 GMT 2013


Le 13 Feb 2013 12:06:12 +0000,
Leo White <lpw25 at cam.ac.uk> a écrit :

> >> A related question is related to the current work on runtime
> >> types. Attributes on type declarations could be kept in the
> >> runtime representation of the declarations, allowing libraries to
> >> interpret them as they want.  (LexiFi's version of OCaml has been
> >> extended with attributes on type declarations precisely to do
> >> that.)  Having attributes defined as general expressions, however,
> >> means that those libraries would need to link with compiler-libs,
> >> or at least be compiled against some of its .cmi, in order to be
> >> able to analyze the Parsetree. I don't see it is as a big problem,
> >> and it would also be possible to restrict which expressions are
> >> reflected in runtime types (e.g. to structured constants).
> >> Comments are welcome!
> >
> >I think it is usualy a bad idea to need to link against
> >compiler-libs. Doing so almost certainly prevent you from being able
> >to compile against different version of the compiler. This ast
> >should be fixed once and be provided in the stdlib. I would also
> >prefer to restrict that kind of annotation to a small subset of the
> >expression language avoiding as much as possible duplication. This
> >would simplify the code using those annotations. Maybe only list,
> >Variant, record and string literals/identifiers would be sufficient.
> >Maybe also let in ?
> 
> I agree that we should avoid making people link against compiler-libs
> where possible. However, I think that having a fixed AST and only
> supporting a subset is too restrictive.
> 
> An alternative would be to provide a standard library module that
> could be used to handle simple ASTs, but still support using
> Parsetree directly for more complicated AST handling.
> 
> For example the "Ast" module might provide functions like:
> 
> getIdent: Ast.expression -> string option
> 
> which would return a string of an identifier if the expression was a
> simple identifier.
> 
> This way we don't restrict changes to Parsetree, or the possible 
> expressions within an attribute, but we do allow people to get basic 
> information out of an expression without linking against
> compiler-libs.

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. 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. 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.

-- 
Pierre
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.ocaml.org/pipermail/wg-camlp4/attachments/20130213/e70ed3d6/attachment.sig>


More information about the wg-camlp4 mailing list