Public Private members?

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Apr 15 19:10:16 UTC 2019


On Mon, Apr 15, 2019 at 05:56:31PM +0000, bauss via Digitalmars-d wrote:
> On Monday, 15 April 2019 at 17:38:15 UTC, Flying-Toast wrote:
> > I am not sure if this is a bug or if there is some explanation for
> > this behavior, but either way it is confusing and I think it should
> > cause an Error.
> > 
> > ---
> > class A {
> >     private {
> >         public int a;//No Error???
> >     }
> > 
> >     private public string s;//Error, expected
> > }
> > ---
> > 
> > https://run.dlang.io/is/odJDnA
> 
> I would argue that it's indeed a bug.

It's a feature. (Though one that I would rather term as a misfeature,
since it makes code needlessly hard to read.)  The main purpose is to
allow you to countermand the 'private' inside a large block of private
members.


T

-- 
It's bad luck to be superstitious. -- YHL


More information about the Digitalmars-d mailing list