--- Comment #4 from bearophile_h...@eml.cc 2010-10-22 04:43:19 PDT ---
(In reply to comment #2)
Thank you for your comments.
> Anyone could define a private tag that doesn't vanish in release mode.
In a union with @tagged the attributes become properties (functions) and they
contain a test over the private tag, to make sure you read the last written
field. You may of course write such proprieties by yourself, but the point of
this feature is to catch possible bugs, and those handwritten properties code
may contain bugs.
> > - Unions may have methods, they are quite more flexible than Algebraic.
> A struct with an Algebraic member can define methods.
But this requires you to change the code that uses the union/struct. While the
@tagged is a clean change that's almost transparent.
> Translation from C is hardly improved as use of union is rather rare.
Usage of low-level features (and simpler porting of existing C code) is what
may give interest in using D instead of for example Java.
This gives 120_000 usages for the word "union" in C:
And 49_000 in C++:
Lower level features too of D may enjoy to become safer, where possible. I have
proposed many other little features that improve the safety of low level D
features. You can't always use high level features in D, and ignoring those
sources of bugs is not good.
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------