dmd 2.063 beta 5

Artur Skawina art.08.09 at gmail.com
Fri May 24 03:54:52 PDT 2013


On 05/24/13 02:33, Steven Schveighoffer wrote:
> On Thu, 23 May 2013 19:03:25 -0400, Artur Skawina <art.08.09 at gmail.com> wrote:
> 
>> On 05/23/13 23:06, Steven Schveighoffer wrote:
> 
>>> compiles:
>>>
>>> struct S
>>> {
>>>    const int x;
>>>    this(int n)
>>>    {
>>>     x = n;
>>>    }
>>> }
>>
>> It's the 'const int x = 42;' case we're talking about. *That* one does not
>> compile and doesn't need to. It /could/, but I see no reason to allow this;
> 
> My example is essentially:
> 
> const int x = 0;

Actually

   const x = int.init;

but these *are* different, and, again - currently the compiler will not allow
mutation - if you add that "= 0" part to your example above it will no longer
compile.
Hence, you are arguing for a change in behavior. And the arguments for that
are extremely weak. The goal should be to allow const initialization to happen
exactly once. The fact some compiler is currently unable to enforce the rules [1]
is not a good argument - the situation will improve eventually. And reversing
such a change later would be harder, as it would break code that started to
rely on the new rules.

artur

[1] /a/ set of rules, even if different from the ones I'm talking about.
    That's a broader topic. In this specific case nothing /needs/ to change,
    so adjusting the definition (if there even is any) is an option.
        


More information about the Digitalmars-d-announce mailing list