DIP64: Attribute Cleanup

Basile B. via Digitalmars-d digitalmars-d at puremagic.com
Mon Apr 18 03:56:19 PDT 2016


On Monday, 18 April 2016 at 10:32:39 UTC, Satoshi wrote:
> On Friday, 20 June 2014 at 19:22:04 UTC, Brian Schott wrote:
>> http://wiki.dlang.org/DIP64
>>
>> Attributes in D have two problems:
>> 1. There are too many of them and declarations are getting too 
>> verbose
>> 2. New attributes use @ and the old ones do not.
>>
>> I've created a DIP to address these issues.
>
> Language defined attribs should be without @ and user defined 
> attribs with @

It's already not the case with @safe, @trusted, @system and 
@nogc. They are not UDAs, they are defined in the language but 
they start with @.

> Whats wrong with it?

- some attributes are also storage classes or type constructors 
(like const).
- It looks strange when you learn.
- It's confusing.
- It's inconsistent in editors (lexing doesn't tells you what 
const is)

If new attributes are added they'll always be @something because 
there's already too much keywords in D.

The first item in the list is interesting because people at the 
beginning often think that

       const int foo(){}

returns a const(int), which is not the case. Here `const` is a 
function attribute, not a type constructor.

The most insane case:

     const(int) foo(const int a) const
     {
        return 0;
     }

Here it should be clear that const as a function attribute should 
be replaced by @const.



More information about the Digitalmars-d mailing list