taggedalgebraic 0.11.0 adds TaggedUnion
Sönke Ludwig
sludwig+d at outerproduct.org
Sat Feb 23 13:25:30 UTC 2019
Am 23.02.2019 um 14:18 schrieb Sönke Ludwig:
> Am 23.02.2019 um 09:51 schrieb Jacob Carlborg:
>> (...)
>>
>> Why not using property syntax, i.e. `val.height = 10`?
>
> The main reason is to distinguish the act of setting a new value from
> the one of modifying an existing value. In the former case it is okay if
> the currently stored kind/type differs, but in the latter case that
> would be a programming error.
To follow up on that, in the example above it would be possible to do this:
val.setHeight(10);
val.heightValue++;
assert(val.heightValue == 11);
//val.captionValue = "foo"; // throws an AssertError
Then there is also a generic variant of the above:
val.set!(Value.Kind.height)(10);
val.value!(Value.Kind.height)++;
val.value!int++;
More information about the Digitalmars-d-announce
mailing list