[wg-camlp4] [Caml-devel] Built-in attributes

Alain Frisch alain at frisch.fr
Tue May 6 05:52:03 BST 2014


On 4/15/2014 6:54 PM, Dario Teixeira wrote:
> As I see it, there are three broad approaches to namespacing:
>
>    1) Namespace nothing.  Use social norms to avoid name clashes between different projects.
>
>    2) Namespace everything, including compiler extensions.  Compiler can even enforce this
>       usage by requiring extension points to be of the form "ns.name".
>
>    3) No namespacing for generic and builtin attributes, such as "default", "warning",
>       or "author", but socially-enforced namespacing for extension-specific attributes.
>
> Here's my problem with solution 2: how do we deal with generic attributes that could be
> used by more than one extension?  (For instance, attribute "default" used by Sexplib
> or Bin-prot, or documentation attributes such as "author" used by tools such as Ocamldoc).
> This is why I'm leaning more towards solution 3.  This approach would require a centrally
> maintained list of non-namespaced attributes (a disadvantage, I admit), but this list
> would be small and fairly static (we could require broad community approval before
> adding another attribute).  All other attributes would be namespaced, though I imagine
> that the namespacing could itself be a social convention (eg. "proj.attr") instead
> of being enforced by the compiler.

A variant of solution 2 is to have each tool accept both qualified and 
unqualified attributes, as I propose in my email about ppx_protobuf.

This gives some flexibility regarding the list of non-namespaced 
attributes, since there is always a way for users to resolve conflicts 
by switching to the qualified form.  It's hard to know in advance if the 
same @default attribute, even if it is recognized by multiple tools, 
would also have the same payload for all of them if used on the same 
code base.

If we apply this to OCaml, we would support both @@ocaml.deprecated and 
@@deprecated.

Opinions?


-- Alain


More information about the wg-camlp4 mailing list