any news on const/invariant?

Walter Bright newshound1 at digitalmars.com
Wed Nov 28 11:51:18 PST 2007


Janice Caron wrote:
> On 11/28/07, Sean Kelly <sean at f4.ca> wrote:
>> You claimed that D does not
>> have storage classes.  Could you explain this?
> 
> Certainly. In the grammar of C and C++, a rule is defined called
> "storage-class-specifier". The "storage-class-specifier" grammar rule
> forms part of the rule defining the syntax of a declaration. There is
> no corresponding grammar element in D.
> 
> The storage class specifiers in C and C++ are auto, extern, mutable,
> register, static and typedef. See the grammar at
> http://www.kuzbass.ru:8086/docs/isocpp/gram.html
> 
> The closest grammar element D has is "attribute". This is defined on
> the web page.
> http://www.digitalmars.com/d/attribute.html. D attributes are
> deprecated, static, final, override, abstract, const, auto, scope, and
> various other constructs as defined on that page.
> 
> Though there is overlap between C's storage classes and D's
> attributes, they are not completely identical, and in consequence,
> some analogies don't work.

I think this is a distinction without a difference. D also has storage 
classes static, extern, etc., which work just like storage classes in 
C++. Syntactically (and the grammar rules for), attributes and storage 
classes are exactly the same.



More information about the Digitalmars-d mailing list