On Sunday, 31 August 2014 at 16:01:10 UTC, Philippe Sigaud via Digitalmars-d-announce wrote:
* Custom signals

enum Signal : string
{ ... }

@nogc Signal customSignal(string name) @safe pure nothrow
    return cast(Signal)name;

I didn't know you could have an enum and extend it with a cast like this. Wow.

This is not a good thing. Enums are supposed to denote a *closed*, enumerated set of items. It's fine here (but IMO bad style) because the author expects there to be user-created values casted to Signal passed to functions/templates that expect a Signal, but this would wreak havoc on code that was expecting a valid enum value (by valid, I mean only one of the predefined enum values).

Reply via email to