How to initialize immutable variables with an expression that throws an exception to catch?

FeepingCreature feepingcreature at gmail.com
Wed Apr 8 06:28:50 UTC 2020


On Tuesday, 7 April 2020 at 19:52:36 UTC, tsbockman wrote:
> On Tuesday, 7 April 2020 at 14:15:20 UTC, FeepingCreature wrote:
>> Right, but that's still the exact same workaround, except with 
>> Nullable instead of Algebraic. I know how to work around it. 
>> I'm saying what should be changed in the language so I don't 
>> *have to* work around it?
>
> The problem in the language is that immutability is considered 
> a permanent and fundamental property of a value, whereas it is 
> actually a state that is entered after the 
> initialization/construction of the value is complete, and 
> exited when the value's memory is later reclaimed.
>
That sounds like a way of thinking that can't be compatible with 
something like `immutable struct S {}`? Because 
https://issues.dlang.org/show_bug.cgi?id=20670 aside, S can't 
really be in a "mutable state", typewise.


More information about the Digitalmars-d mailing list