Search code examples
d

Protected module members


According to D docs (http://www.digitalmars.com/d/2.0/attribute.html#ProtectionAttribute) protected module members are illegal, but compiler allow me to do this.

module foo;
protected
{
    int bar; 
}

Is this error in docs, compiler bug or I am doing something wrong ?
Actually this is not the only inconsistency between documentation and reality, so is this reference (http://www.digitalmars.com/d/2.0) are actual ? Is more actual language description exist somewhere ?
My configuration: dmd 2.047, OS Windows 7, x86


Solution

  • The compiler allows attributes in places where they don't have any effect. This is unfortunate, because it is confusing. Hopefully they will eventually be disallowed, like some of them already have.

    The online documentation is not complete. If you're serious about learning D, you might want to buy the book "The D Programming Language" by Andrei Alexandrescu. It was released just a month ago. It covers some things that the online documentation doesn't. And vice versa.

    You can find a lot of answers by searching the D newsgroup archives, or by asking in the newsgroup, searching the digitalmars site, the D wiki, etc. The docs themselves probably won't be updated for years, though.