[Issue 5097] Safer unions with @tagged
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Oct 21 20:01:16 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5097
Andrei Alexandrescu <andrei at metalanguage.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |andrei at metalanguage.com
Resolution| |INVALID
--- Comment #2 from Andrei Alexandrescu <andrei at metalanguage.com> 2010-10-21 20:00:28 PDT ---
(In reply to comment #1)
> 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.
This does not justify a new language feature. Anyone could define a private tag
that doesn't vanish in release mode.
> - Unions may have methods, they are quite more flexible than Algebraic.
A struct with an Algebraic member can define methods.
> - 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).
Translation from C is hardly improved as use of union is rather rare.
--
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