Multiple attribute specifiers

Ary Manzana asterite at gmail.com
Thu Sep 7 05:25:15 PDT 2006


Stewart Gordon wrote:
> 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.

In some post of the "learn" list someone said the last attribute should 
be taken. I think this is ok, but it should be better to issue an error 
(or at least a warning) because it's pretty ugly or counter-intuitive.

> 
>> 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?

I mean that if I want to implement a compiler, or, say, a plugin for 
Eclipse, I need to know this things and not just make guesses or see how 
the compiler works. At least it should be in the specifications.

> 
> Stewart.
> 

Ary



More information about the Digitalmars-d-bugs mailing list