Here is a better example that can actually be implemented but not pretty:


final immutable struct Msg
{
    immutable int Foo = 0;
    immutable int Bar = 1;
    final immutable struct Type
    {
        immutable int Error = 10000;
        immutable int Ok = 10001;
    }
}

Here type is not necessarily a logical subtype of Msg but better stated as Msg.Type.Error rather than MsgType.Error.

If a flag distribution was used, we could do Msg.Foo || Msg.Type.Error.

In any case generating such a structure is a bit of a pain compared to a normal enum.

Reply via email to