[wg-camlp4] [Caml-devel] Keeping attributes in .cmi files?

Jacques Garrigue garrigue at math.nagoya-u.ac.jp
Thu Sep 19 01:25:46 BST 2013

On 2013/09/18, at 18:34, Alain Frisch <alain.frisch at lexifi.com> wrote:

> Dear all,
> Attributes are currently kept in .cmt and .cmti files, which are dumps of the Typedtree counterparts of .ml and .mli files.  This allows external tools to access those attributes together with the output of the type-checker.  But this does not easily allow the compiler itself (which doesn't parse the .cmti file) to see attributes from external units.
> If we keep attributes also in the internal structure of the type-checker, which is dumped in the .cmi file, we can make the compiler aware, for instance, of attributes put on value declarations.
> As an example, see the following discussion about having the compiler report a warning when a value marked as deprecated is being used:
> http://caml.inria.fr/mantis/view.php?id=5854
> Attributes give a natural way to mark values as deprecated, and as I suggest in the discussion, the simplest way to use this information is to keep it in the Types.value_description record (and thus in .cmi files).
> If we start having the compiler understand some specific attributes, it makes sense, in my opinion, to keep them even in .cmi files (at least for attributes on "declarations", not necessarily on type expressions).  Do you agree?  Would anyone object to the patch I proposed on the ticket above?

On the principle, I have nothing against keeping attribute in .cmi files, since they are not supposed to change.
But to be honest I have not followed the discussion on attributes, and the inclusion in trunk was kind of sudden.
It might have been better to wait for the upcoming meeting.

I am a bit concerned by the fact the syntax tree is now completely mutually recursive:
an attribute appearing in a type may contain a structure.
What is the rationale behind that ?
And for pattern attributes in types ?
Does it mean that you want to include whole structures in .cmi files ?
Wouldn't it be better to restrict attributes to type expressions, constants, and identifiers/paths ?
Should all nodes allow all attributes ?


More information about the wg-camlp4 mailing list