any news on const/invariant?

Janice Caron caron800 at googlemail.com
Wed Nov 28 02:59:07 PST 2007


On Nov 28, 2007 10:10 AM, Walter Bright <newshound1 at digitalmars.com> wrote:
> I think it would be pretty hard to give up:
>
>         const x = 3;
>
> Also, C++ has const as both a storage class and a type constructor, and
> yes, they have subtly different meanings. This doesn't seem to cause any
> major problems.


Actually, I may have been misunderstood, so I want to be clear. There
is a difference between an ATTRIBUTE and a STORAGE CLASS. C++ has
storage classes, but D does not. D has attributes, but C++. They are
not the same thing. The terms are not interchangeable.

For example, in C++, "typedef" is (syntactically) a storage class, but
it's certainly not an attribute in D.

If you want to make the statement

    const x = 3;

legal in D, it is perfectly possible to do that without making "const"
an attribute. You only have to define a "const statement" or something
in the grammar. Call that a "storage class" if you want, but you don't
have to grant the keyword all the power of an attribute.

To keep this conversation plain, let us not confuse the terms
"attribute" and "storage class" again.



More information about the Digitalmars-d mailing list