Proposal: Definition of @-attributes

Roman Ivanov isroman-del at ete-km.ru
Thu Jan 28 09:09:26 PST 2010


Lars T. Kyllingstad Wrote:

> In the "Function calls" thread the question of "which attributes should 
> be in the @-namespace" has again come up.
> 
> 
> Problem:
> Currently, there doesn't seem to be any clear definition of which 
> attributes should be prefixed with @ and which shouldn't.  New 
> attributes get an @, while already existing attributes don't, and it all 
> seems a bit arbitrary.  Then again, we probably don't want *all* 
> attributes to be written with @, as that would just make code look messy:
> 
>      @safe @nothrow @private @property int foo() { ... }

I'm not saying D should do this, but in my opinion placing those things before function name and return type isn't very readable once you get more than two modifiers, regardless of whether you use @ or not. Compare:

int foo() safe nothrow private property { ... }

This is especially true if you have user-defined attributes, because you no longer have to think about where is return type name and where is the attribute. The method signature is visually separated by the parenthesis:

SomeType foo() private somethingable { ... }
vs
@somethingable private SomeType foo() { ... }



More information about the Digitalmars-d mailing list