On 6/2/15 6:50 PM, Andrei Alexandrescu wrote:
On 6/2/15 1:48 AM, Manu via Digitalmars-d wrote:
On 2 June 2015 at 05:00, deadalnix via Digitalmars-d
<[email protected]> wrote:
After discussion at DConf, it ends up that union have some lack of
specification, and some nonsensical behavior right now. Here are some
points
discussed and possible solutions :
1/ .init for unions is not defined. I propose to define it as the
.init of
the first field + padding with 0s if the union is larger than its first
member. It seems to be what is generated right now.
Isn't it the case that some of the members of a union need to be
declared with init =void, such that only one version of the union
provides the init values?
At that point, isn't the state of init clearly defined by the members
that aren't =void?
That could be done, but strikes me as too clever for its own good. --
Andrei
It's actually unnecessarily redundant. In all cases, you can simply move
the "valid" one to the first member. Initing the first member is the
right call.
-Steve