accept @pure @nothrow @return attributes

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Wed Jan 28 07:37:18 PST 2015


On Wednesday, January 28, 2015 15:16:50 via Digitalmars-d wrote:
> On Wednesday, 28 January 2015 at 15:11:35 UTC, Jonathan M Davis
> wrote:
> > consistent. They're
> > always going to be inconsistent in one way or another, even if
> > it's simply
> > because they don't match what anyone coming from other
> > languages expects
>
> The logical conclusion from that statement would be that D
> semantics are fundamentally broken...

Not really. For instance, we could make the attributes "completely
consistent" by adding @ to all of them - @pure, @public, @const, etc. But
that would cause inconsistencies with other languages that have many of the
same attributes, and it would likely cause far more complaining than the
current situation has.

We could also remove @ from all of the attributes, and then that would be
"completely consistent," because then only UDAs will have @ on them. But the
next time that we need to add a new attribute (which will hopefully be rare,
but it happens sometimes - e.g. with @nogc recently), then we'd have to add
a new keyword to avoid making things inconsistent, which would likely break
existing code. So, more likely, we'd just tack @ onto it (which can still
break code, but only UDA-specific code, so the breakage would be far more
minimal), and we'd be right back where we are now.

And any situation where some of the attributes have @ on them and some don't
will almost certainly result in arguments about whether the rationale makes
sense and whether one or more of the attributes really belongs in the camp
that it's in, so how consistent it is would depend on the eye of the
beholder.

I don't see any of that as being something fundamentally broken with the
semantics of D. It's just life with designing a programming language -
especially one which isn't 100% set in stone. There are _always_
inconsistencies and annoying points in the language. And much of the time,
those inconsistencies and annoying points are forced by other aspects of the
language that actually make things nice and clean. There are always
tradeoffs, and often, there is no clear, right answer to how it should be.
And I think that this is one of those cases.

- Jonathan M Davis



More information about the Digitalmars-d mailing list