DIP 1012--Attributes--Preliminary Review Round 1
Johannes Pfau via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jul 27 23:31:08 PDT 2017
Am Thu, 27 Jul 2017 23:38:33 +0000
schrieb Nicholas Wilson <iamthewilsonator at hotmail.com>:
> On Thursday, 27 July 2017 at 15:48:04 UTC, Olivier FAURE wrote:
> > On Thursday, 27 July 2017 at 14:44:23 UTC, Mike Parker wrote:
> >> DIP 1012 is titled "Attributes".
> >>
> >> https://github.com/dlang/DIPs/blob/master/DIPs/DIP1012.md
> >
> > This DIP proposes a very complex change (treating attributes as
> > Enums), but doesn't really provide a rationale for these
> > changes.
>
> It is actually a very simple change, from the end user
> perspective.
> * Function attributes that were keyword like, become regular
> attributes.
> * They can be applied to modules, acting as a default for
> applicable symbols in the module.
>
I think it also makes sense from a compiler perspective. When these
attributes were introduce, we didn't have UDAs yet. Then we introduced
UDAs and now UDAs are more full-featured than the original compiler
hardcoded attributes:
UDAs do not introduce names into the global namespace, UDAs can use
fully qualified names, multiple UDAs can be combined or aliased (as
commonly done in C for dll export attributes using #defines. We can't
do such things in D right now). So I think moving the compiler
attributes to UDAs is certainly useful.
But it seems this DIP fails to stress the rationale and confuses people
with some implementation detail. I think it's important to show the
simple use cases, where object.d auto imports everything and aliases
are used so you can use normal @nogc void foo()... syntax. Then maybe
show how to group or alias attributes.
-- Johannes
More information about the Digitalmars-d
mailing list