dmd 2.063 beta 5

Don turnyourkidsintocash at nospam.com
Thu May 23 09:09:26 PDT 2013


On Thursday, 23 May 2013 at 13:52:49 UTC, Steven Schveighoffer 
wrote:
> On Thu, 23 May 2013 05:05:01 -0400, Don 
> <turnyourkidsintocash at nospam.com> wrote:
>
>> On Tuesday, 21 May 2013 at 20:36:20 UTC, Walter Bright wrote:
>>>
>>> Join the dmd beta mailing list to keep up with the betas. 
>>> This one is pretty much good to go, unless something 
>>> disastrous crops up.
>>>
>>> http://ftp.digitalmars.com/dmd2beta.zip
>>>
>>> Remaining regressions:
>>>
>>> http://d.puremagic.com/issues/buglist.cgi?query_format=advanced&bug_severity=regression&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED
>>
>> NO NO NO NO. I am violently opposed to this release.
>>
>> This beta contains the worst language misfeature of all time. 
>> It's silently snuck in under the guise of a bugfix.
>>
>>
>> struct S
>> {
>>     const int x = 7;
>>     int y;
>> }
>>
>> In previous releases, S.x was always 7.
>> But now, if you write
>>
>> S s = S(5);
>>
>> then x gets changed to 5.
>> This means that the const variable x has been initialized 
>> TWICE!
>
>> This new behaviour is counter-intuitive and introduces a 
>> horrible inconsistency.
>
> I disagree.
>
> struct S
> {
>      const int x;
> }
>
> S s1; // x is 0


Of course! It's an uninitialized variable! Try making x a float, 
and you'll get NaN.

> S s2 = S(5); // x is 5

---
> I can see uses.  If you don't want x.init to be the default for 
> x, then you need to set it to something else.
>
> For example:
>
> struct Widget
> {
>    immutable string name = "(unset)"; // instead of ""
> }

That is just an awful workaround for the lack of default 
constructors.


More information about the Digitalmars-d-announce mailing list