immutable struct/class is mutable!

JS js.mdnq at gmail.com
Mon Jul 15 11:39:07 PDT 2013


On Monday, 15 July 2013 at 15:08:58 UTC, Dicebot wrote:
> On Monday, 15 July 2013 at 14:50:04 UTC, JS wrote:
>> Why does isMutable and isAssignable return true for a 
>> struct/class that are immutable?
>>
>> immutable struct A { }
>>
>> isMutable!A returns true.
>
> looks like
>
> immutable struct A
> {
>     int a;
> }
>
> acts as a
>
> struct A
> {
>     immutable:
>         int a;
> }
>
> Now, I don't see this use case (qualified aggregate definition) 
> anywhere in spec and this may be intended behavior. But I do 
> agree this looks misleading.

and immutability doesn't nest. immutable struct A { struct B { 
}}, struct B is mutable.



More information about the Digitalmars-d-learn mailing list