static class

Jonathan M Davis jmdavisProg at gmx.com
Thu Feb 21 20:04:52 PST 2013


On Friday, February 22, 2013 00:59:45 Ary Borenszweig wrote:
> On 2/21/13 8:34 PM, Jonathan M Davis wrote:
> > 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.
> 
> If the compiler gave you an error if you put "static" on a top-level
> class definition, this whole thread wouldn't exist.
> 
> Don't you see that as a problem? People loosing their time answering
> this questions over and over again instead of the compiler giving you
> the answer.

I'm not talking about static. I'm talking about the fact that putting both 
final and abstract on a class isn't a problem.

In general, I do agree that the fact that the compiler doesn't complain about 
inapplicable attributes is a problem. There are some good arguments with 
regards to generic programming which make it so that having the compiler 
complain could be problematic, but I'm not completely convinced that we can't 
have the compiler complain at least _some_ of the time. And as for static in 
particular, I doubt that it ever makes sense for it not to be complained about 
if it's used where it doesn't apply. But Walter doesn't see it as a problem. I 
suspect that a detailed analysis (possibly even a DIP) would be required to 
show where it would make sense to make inapplicable attributes illegal and 
where it wouldn't. Certainly, just complaining about it won't convince Walter.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list