On Saturday, 2 January 2016 at 10:04:47 UTC, Shriramana Sharma
wrote:
I thought the promise of `immutable` was: never changes.
The compiler doesn't protect you by carrying a bomb. :)
But there is another usecase where it makes sense to allow
writing to other union members despite the overlap with immutable
data:
enum Types {Integer, Text, CalculationConstant}
struct oldStyleLimitedBadVariant // Don't use that! D offers
std.variant.Algebraic..
{
Types type;
union
{
int integer;
string text;
immutable float calculationConstant;
}
}
There i would expect that i can write to integer and text at any
time.
togrue