std.sumtype?
Oleg B
code.viator at gmail.com
Wed Mar 31 17:06:05 UTC 2021
On Tuesday, 23 March 2021 at 14:45:18 UTC, Atila Neves wrote:
> On Friday, 19 March 2021 at 07:28:19 UTC, drug wrote:
>> On 3/18/21 9:42 PM, Oleg B wrote:
>>>
>>> but read-only tag (kind, type index) is key feature in chouse
>>> between sumtype and other for me, and I hope it will be added
>>> before next compiler release...
>>>
>>
>> Totally agree, it is an important feature.
>
> Can anyone explain to me why?
Simple general example is serialization and deserialization of
algebraic value: without tag (kind, type index) it's not
impossible but more complicated. For serialization you need write
tag first (`match` is good for serialization exist value) and
then deserialize you need to read tag and do deserialization for
writed value type (how it must be with `match`?). If tag is
private and/or it not direct point to types you need "jump
through hoops" for this simple algo.
More information about the Digitalmars-d
mailing list