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

Iain Buclaw via Digitalmars-d digitalmars-d at puremagic.com
Fri Oct 10 10:31:46 PDT 2014


On 10 Oct 2014 17:35, "Walter Bright via Digitalmars-d" <
digitalmars-d at puremagic.com> wrote:
>
> 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.
>

You shouldn't be blaming C++ for mistakes that D made.

> 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.
>

Equally, static does not have a double-meaning.

Iain.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20141010/f9dc7655/attachment.html>


More information about the Digitalmars-d mailing list