[Issue 1441] Allow 'private' to restrict class visibility outside module or outer class

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 10 12:45:44 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=1441





------- Comment #4 from jarrett.billingsley at gmail.com  2009-04-10 14:45 -------
(In reply to comment #3)
> 1. http://www.digitalmars.com/d/2.0/attribute.html#ProtectionAttribute
> talks of "members".  Should we interpret this to include arbitrary members of a
> module?

Sure.  That's more or less what this ticket is suggesting.

> 2. Where does the spec state that it's legal to use attributes that are not
> applicable to the entity to which they're applied?  Otherwise it's reasonable
> to assume that, should the compiler fail in its attempt to apply an attribute
> to something, this failure is supposed to be by means of generating an error.

Two problems.  One, the spec is silent on this issue, so it's logically
inconsistent to conclude that by not issuing an error, the compiler is acting
incorrectly.  In effect there is no "correct" behavior because there is no
specified behavior; assumptions mean nothing.  

Two, if you want the compiler to give an error about inapplicable attributes,
put it in another ticket.  That particular behavior encompasses far more than
just public and private on classes, but also things like final, static, extern
etc.

> 3. Making a class or similar entity private makes perfect sense.  Silently
> ignoring attempts to do so makes absolutely none.

Again, what the compiler should do with inapplicable attributes is a separate
issue from what 'private' on a class should mean.  This ticket is an
enhancement request; your request is more one for clarification of the spec.


-- 



More information about the Digitalmars-d-bugs mailing list