On 11/18/2014 11:01 AM, Steven Schveighoffer wrote:

> This works in C++:
>
> struct S
> {
>     union
>     {
>        const char *myString;
>     } Value;
> };
>
> But the issue is that D does not require the semicolon at the end of the
> struct, so by the closing brace, it is done with the union.

Interesting. It never occurred to me that the lack of semicolons could have that effect.

> the closest solution you can get is the last one you said.
>
> I never even considered that you can't make an anonymous struct or union
> type and assign it to a member in D. Not sure if we really need to
> support it though.

I wouldn't miss that feature. :)

If I am not mistaken, the only "benefit" of anonymous types is that they cannot refer to themselves. I remember reading in a C++ thread years ago that anonymous types could not have contructors, destructors, and assignment operators either because they could not spell out the name of the type to define such functions.

Ali

Reply via email to