www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - static attribute on class declaration

reply "John C" <johnch_atms hotmail.com> writes:
Purely by accident, I discovered that the compiler doesn't issue an error 
when the static attribute is used in a class declaration, like so:

    public static class MyClass {
    }

It doesn't appear to be documented, so does it have a purpose? I initially 
thought it might be a shorthand for final and abstract (classes that can 
neither be instantiated nor derived from), but no.

Anyway, just curious.

John. 
Mar 12 2005
parent reply "Walter" <newshound digitalmars.com> writes:
"John C" <johnch_atms hotmail.com> wrote in message
news:d102ra$skm$1 digitaldaemon.com...
 Purely by accident, I discovered that the compiler doesn't issue an error
 when the static attribute is used in a class declaration, like so:

     public static class MyClass {
     }

 It doesn't appear to be documented, so does it have a purpose? I initially
 thought it might be a shorthand for final and abstract (classes that can
 neither be instantiated nor derived from), but no.
Because of the way attributes are parsed, ones that make no sense are just ignored. This is for things like: static: // everything that follows is static
Mar 12 2005
parent "Craig Black" <cblack ara.com> writes:
 Because of the way attributes are parsed, ones that make no sense are just
 ignored. This is for things like:

    static:

    // everything that follows is static
Cool. -Craig
Mar 14 2005