Multiple attribute specifiers
Stewart Gordon
smjg_1998 at yahoo.com
Wed Sep 6 12:44:06 PDT 2006
Ary Manzana wrote:
> If I write this inside a module:
>
> --------------------------------------
> public private int x;
> --------------------------------------
>
> it compiles perfectly.
>
> What is the protection level of x? public or private? Well, you can try
> compiling it and using it to find out, but I think the compiler should
> issue a warning or, much better, an error.
It should _definitely_ issue an error. I call this a bug indeed.
> This confusion also appears if I write
>
> --------------------------------------
> public {
>
> private {
>
> int x;
>
> }
>
> }
> --------------------------------------
>
> Again, the same question. Is x public or private?
When one protection attribute appears within an attribute block that
specifies another, the inner one overrides.
> I was going to post this to the digitalmars.D.bugs list, but I want some
> comments on this before proceeding.
The .bugs 'group contains a lot more than issues that people are
_certain_ are bugs. Indeed, it's quite a good place to discuss
behaviour that looks like a bug.
> I know no one would want to write such a thing, but on the compiler side
> (or other tools) it is crucial to know what should be the semantic
> (because currently it's legal).
By "legal", I take it you mean the compiler accepts it. By "the
semantic", do you mean what the compiler does with it?
Stewart.
--
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d- s:-@ C++@ a->--- UB@ P+ L E@ W++@ N+++ o K-@ w++@ O? M V? PS-
PE- Y? PGP- t- 5? X? R b DI? D G e++++ h-- r-- !y
------END GEEK CODE BLOCK------
My e-mail is valid but not my primary mailbox. Please keep replies on
the 'group where everyone may benefit.
More information about the Digitalmars-d-learn
mailing list