Make const, immutable, inout, and shared illegal as function attributes on the left-hand side of a function

Yota via Digitalmars-d digitalmars-d at puremagic.com
Fri Oct 10 09:28:18 PDT 2014


On Friday, 10 October 2014 at 02:38:42 UTC, Walter Bright 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
>
> In particular,
>
>    const T *v;
>
> does not mean:
>
>    const(T)* v;

Once again, I am thoroughly confused as to why the space is put 
before the * in a language where the * is associated with the 
type, and not the identifier.  If it had been written like

const T* v;

Then it would be obvious that it means

const(T*) v;

At which point I ask, why word it such that 'const' affects the 
symbol v, and not the type T*?  And why does the former syntax 
even exist if it is more proper to use the latter?


More information about the Digitalmars-d mailing list