On Tuesday, 21 May 2013 at 20:36:20 UTC, Walter Bright wrote:
NO NO NO NO. I am violently opposed to this release.
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
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.
This is totally different to what happens with module constructors (you get a compile error if you try to set a const global if it already has an initializer). Likewise, everywhere else in the language, when you see a const variable with an initializer, the initializer gives its value.
I think the only possible solution is to make it an error to provide a const or immutable member with an initializer.
If you are providing an initializer, you surely meant to make it 'static const', and that is certainly true of all existing usages of it.
As far as I can tell, this new feature exists only to create bugs. No use cases for it have been given. I cannot imagine a case where using this feature would not be a bug.
Please do not release this beta.