Const/Shared/Immutable anomalies in D that should be fixed

Chris Cain clcain at uncg.edu
Thu May 3 01:18:12 PDT 2012


On Thursday, 3 May 2012 at 07:45:53 UTC, Chris Cain wrote:
> The straightforward answer to this is that you really ought to 
> have a main method :-)
> ...

Well, I just updated DMD to 2.059 (from 2.058) and lo and behold, 
this doesn't pass for the new version. Interesting. And 
apparently static asserts can now occur outside of a scope (must 
have been a fixed bug).

That said, I'm receptive to the change because I don't see a use 
case for the original behavior and I buy Mr. Davis' explanation.

Plus this:
void main() {
     immutable(Immutable) a;
     Immutable b;
     static assert(!is(typeof(a) == typeof(b));
}
would fail with the old behavior, even though they are clearly 
distinct.

And of course is(typeof(anImmutable) == shared) is also false 
with the new version.


More information about the Digitalmars-d mailing list