static class

Jonathan M Davis jmdavisProg at gmx.com
Thu Feb 21 15:34:23 PST 2013


On Friday, February 22, 2013 00:06:26 bearophile wrote:
> Jonathan M Davis:
> > D doesn't
> > bother to check, so you get the natural consequence of mixing
> > them. I'm quite
> > sure that the fact that it works that way is an accident. It
> > was never
> > intentially made to be allowed or disallowed. It's just
> > allowed, because
> > there's nothing intrinsic about either of the attributes which
> > makes it
> > illegal, and no effort was made to do prevent it (it probably
> > didn't even occur
> > to Walter that anyone would do it). I'd expect it to continue
> > to work though,
> > since it doesn't really harm anything,
> 
> According the way my brain works, sometimes I find the D compiler
> unnervingly sloppy.

True enough, but in this case, I don't think that it's a problem. The way 
these parts work together is the logical conclusion of how they work 
separately. It's the stuff like outright ignoring invalid attributes which 
tends to be problematic.

> > and it would break code if it were disallowed.
> 
> Uhmm.

What's the confusion? People have been using the idiom of marking classes as 
both abstract and final in order to effectively create namespaces. Any code that 
does that would break if marking a class as both abstract and final were made 
illegal. IIRC, even a couple parts of Phobos do it (though Andrei and Walter 
are both generally against the idiom, preferring that free functions be used 
rather than trying to create namespaces out of other features when namespaces 
were never meant to be a feature of D).

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list