Why do some attributes start with '@' while others done't?

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Fri Jan 22 01:55:46 PST 2016


On Friday, 22 January 2016 at 00:24:13 UTC, Dibyendu Majumdar 
wrote:
> On Thursday, 21 January 2016 at 23:18:16 UTC, tsbockman wrote:
>> A revision of D that wasn't constrained by backwards 
>> compatibility would almost certainly either require all 
>> attributes to be prefixed by @, or change the grammar such 
>> that attribute names could be reused as identifier names 
>> without introducing ambiguities.
>
> It seems to me that '@' could be allowed as optional prefix to 
> attributes that currently don't have it without breaking code - 
> or am I being naïve?

Sure, but that complicates the compiler, it will probably 
marginally harm compilation times, and it will then result in 
some code using @ and some not for the same attribute - possibly 
even in the same codebase, which will just increase confusion to 
no real benefit. And we haven't even agreed that putting @ on 
attributes that don't currently have it is even desirable.

So, if we decided that we definitely wanted @ on all attributes 
(or any particular set of attributes that don't currently have 
it), then we could do something like you suggest as a deprecation 
path and eventually make the @ required, but it really wouldn't 
make sense to leave it up to the programmer to decide which they 
want and just leave it that way, and we haven't decided that we 
want @ on all attributes anyway.

- Jonathan M Davis


More information about the Digitalmars-d mailing list