immutable constructor and semantics of two construction syntaxes

Ali Çehreli acehreli at yahoo.com
Sat Apr 13 17:48:36 PDT 2013


When immutable constructors are implemented, will there be a difference 
between the two syntaxes below?

struct MyStruct
{
     int i;

     // ... assume that MyStruct has both
     // mutable and immutable constructors ...
}

     auto s0 = immutable(MyStruct)("some parameter");

     immutable s1 = MyStruct("some parameter");

The former syntax constructs an immutable literal, so the type of s0 is 
deduced to be immutable.

The latter syntax constructs a mutable literal and blits it to the 
immutable s1.

Should the former syntax call the immutable constructor and the latter 
syntax call the mutable constructor?

Ali


More information about the Digitalmars-d mailing list