D - extending enums
- Pavel Minayev (12/12) Nov 24 2001 I thought it would be fine if enums were extensible:
- Walter (4/16) Nov 24 2001 This idea has come up before, and it's a good one. -Walter
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... =)
Nov 24 2001
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... =)
Nov 24 2001