November 24, 2001 extending enums | ||||
---|---|---|---|---|
| ||||
I thought it would be fine if enums were extensible: enum Color { red, green, blue }; // somewhere later enum Color { yellow, cyan, magenta }; // Color.yellow = Color.blue + 1 Not useful as is, but could be very handy if applied to class hierarchy. So the base class declares the enum and introduces basic options common for all, and then child classes add options specific to their functionality. Or maybe use the class syntax for enums, with inheritance and such? A stupid idea, probably, but... =) |
November 24, 2001 Re: extending enums | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | This idea has come up before, and it's a good one. -Walter "Pavel Minayev" <evilone@omen.ru> wrote in message news:9to6n8$12d6$1@digitaldaemon.com... > I thought it would be fine if enums were extensible: > > enum Color { red, green, blue }; > // somewhere later > enum Color { yellow, cyan, magenta }; // Color.yellow = Color.blue + > 1 > > Not useful as is, but could be very handy if applied > to class hierarchy. So the base class declares the > enum and introduces basic options common for all, and > then child classes add options specific to their > functionality. > > Or maybe use the class syntax for enums, with inheritance and such? A stupid idea, probably, but... =) > > > |
Copyright © 1999-2021 by the D Language Foundation