On 10/10/2014 8:15 AM, Martin Nowak wrote:
const is used both as a storage class and as a type constructor, and is
distinguished by the grammar:

    const(T) v; // type constructor, it affects the type T

    const T v;  // storage class, affects the symbol v and the type of v

That on it's own is fairly difficult to explain.

I can blame C++ for that, because in C++ the difference between const as storage class and as type constructor is much more subtle than in D, but it has critical affects.

This problem is why we chose the const(T) syntax for type construction.

As for "what is a storage class" is there any confusion about:

    static T v;

? I don't think so.


For functions, const-as-storage-class applies to the function symbol.

What's the difference between a const symbol and a normal symbol?

A const field member, for example, didn't contribute to the size of the struct.


We don't want to break code, but discourage the usage of LHS function qualifiers
because they are confusing.
As this is more about stating a clear preference than deprecating the old syntax
let me propose a compromise.

- adding RHS rule to D's style guide http://dlang.org/dstyle.html
   with an explanation what the storage class function thing does

- change any dmd formatting code to RHS and change our documentation

- leave the rest to linting tools like https://github.com/Hackerpilot/Dscanner

That's a good idea. I have no objections.

Reply via email to