[Issue 5097] Safer unions with @tagged

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 21 18:41:23 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=5097



--- Comment #1 from bearophile_hugs at eml.cc 2010-10-21 18:40:42 PDT ---
This is not the same as std.variant.Algebraic because:
- There is no way for the programmer to read the tag, because the tag and its
tests vanish in release mode.
- Unions may have methods, they are quite more flexible than Algebraic.
- If you translate C code to D you may not want to modify too much the code, so
you will not use Algebraic. But you may add the @tagged attribute to unions
translated from C. The size of the union changes, but hopefully this doesn't
cause disasters often (if changing the size of the union is seen as not
acceptable, then the union tags may be stored elsewhere on the heap and stack,
but this may increase the implementation complexity of this feature).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list