November 03, 2005
How can you simulate enumeration inheritance so that later enums can automatically adopt all the constants of an earlier one?

Application: I have basic messages that all GUI objects support and more specific messages to each type. Obviously a Button should messages specific to Lists (and vice versa) but they both understand things like redraw, move, destroy...

I could fully qualify the enum reference every time I wanted to use something from the main class, but ... I'm in no hurry to develop carpal tunnel :) I could use mixins except they don't seem to work for enums (complains about items separated by commas rather than semicolons).

Ideas? (I'm using enums for good reason)
Thank you.

November 03, 2005
> Ideas? (I'm using enums for good reason)

Hmmm.. A static foreach comes to mind :-) No, don't look for it, it's not there.

For the record, I remember an interesting point raised by Walter a few years ago: 'inherited' enums would behave differently from inherted classes in that an inherited class can be cast safely to the base, but an inherited enum (one with more values) cannot. In fact, the base enum can be cast to the inherited one.. I've always thought this was an interesting point.


Top | Discussion index | About this forum | D home