The state of contract programming in D

Stewart Gordon smjg_1998 at yahoo.com
Tue Mar 6 07:44:57 PST 2012


On 06/03/2012 15:19, Alex Rønne Petersen wrote:
<snip>
> Shouldn't invariant as a type modifier be deprecated once and for all? I mean, immutable
> has existed for a long time now...

It already is deprecated.  Download a current DMD version and see for yourself.

But how does this help?  The ambiguity isn't gone until this use of invariant is removed 
from the language/compiler completely.

> Also, just so we're on the same page here, you mean the parentheses, right? If so, I'm not
> sure I quite understand where the problem arises. Could you elaborate?

invariant {
     int id;
     char[] name;
}

Is this a block of class-level invariant member declarations, or a class invariant that 
does nothing but declare two local variables?

Since D2's early days it has dealt with it by using invariant() for the latter.

Stewart.


More information about the Digitalmars-d mailing list