Weird rule for immutable

Victor Porton porton at narod.ru
Sat Apr 11 01:45:20 UTC 2020


On Saturday, 11 April 2020 at 01:26:28 UTC, Adam D. Ruppe wrote:
> On Saturday, 11 April 2020 at 01:19:29 UTC, Victor Porton wrote:
>> Why this is disallowed?
>
> Immutable means it NEVER changes. If you want it to just 
> temporarily not change, that's what const is for.

Yes, specification reads this way by me, too.

But is there any practical reason that the specification 
disallows the following?

int[] x = [];
{
   immutable y = cast(immutable)x;
}
x = [1, 2];


More information about the Digitalmars-d mailing list