On Friday, 20 June 2014 at 22:01:31 UTC, Timon Gehr wrote:
On 06/20/2014 09:22 PM, 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.

Why not make the built-in attributes proper symbols instead and use

alias Seq(T...)=T;
alias spiffy = Seq!(pure,nothrow,safe);

float mul(float a, float b) @spiffy{ }

?

This will also allow use cases such as passing attributes by alias.

I think this would make the language a lot cleaner, and can be taken even further:

  @extern("C++", "some.namespace")
  class C {
    @private int x;
  }

Here `extern` is a regular function that returns an instance of some compiler-defined type. This makes "built-in" attributes just particular cases of properties (that happen to be recognized by the compiler).

"Attribute" and "property" are pretty much synonyms in English, and it always seemed strange to me that D had to define them as different--yet confusingly similar--entities.

Reply via email to