Article View: comp.std.c++
Article #78Re: Expanding enumerators in inheriting classes
From: Tucker Taft
Date: Tue, 11 Aug 1992 19:08
Date: Tue, 11 Aug 1992 19:08
47 lines
3037 bytes
3037 bytes
In article <1992Aug11.133926.28840@actrix.gen.nz> Bruce.Hoult@bbs.actrix.gen.nz writes: >In article <1992Aug10.200814.12809@ntmtv> hildum@ntmtv.UUCP (Eric Hildum) writes: >> A language feature that I would like to see is support for inheritance upon >> the builtin type enumerator. That is, I would like to define a number of >> enumerators for an enumeration type, then use that enumeration type as a base >> for a second enumerator with an expanded enumerator set, incorporating all the >> base types enumerators and adding a number of new enumerators. >> >> Has something like this extension been suggested anywhere? > >When Wirth was adding object-oriented features to Modula-2 in creating >Oberon he used the term "type extension" where we C++ers would use >"derivation". > >Being a fan of orthogonality (where sensible) he wanted to be able to apply >type extension to enumerated types. It seems that he could find no good way >to do it and instead dropped enumerated types from the language entirely! > >Perhaps there is something nice that Wirth missed (and I seem to >remember something about the problems in the Oberon documentation) but I >wouldn't bet the farm on it... :-) > >-- Bruce We considered supporting enumeration type extension in Ada 9X, but ultimately dropped it. One issue (among others) was that values from distinct enumeration extensions of a parent enumeration type might have the same associated integer "code," making direct comparison between them less meaningful. That is, equality could be defined, but less-than/greater-than became relatively meaningfless. One reason we lost interest was the observation that record extension/derivation tends to make enumeration types less necessary. Rather than having a variant record/union type with a value of an enumeration type distinguishing the variants, one would simply define distinct derivations. A virtual function could return a string name for each distinct derivation, corresponding to the enumeration literal. A separate virtual function could return an integer code, if needed. >Bruce.Hoult@bbs.actrix.gen.nz Twisted pair: +64 4 477 2116 >BIX: brucehoult Last Resort: PO Box 4145 Wellington, NZ >"Cray's producing a 500 MIPS personal computer with 256MB RAM and 8 GB >hard disk that fits in your pocket!" "Great! Is it PC compatible?" S. Tucker Taft stt@inmet.com Intermetrics, Inc. Cambridge, MA 02138
Technical Details
Message-ID:
<1992Aug11.190816.8623@inmet.camb.inmet.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!inmet!spock!sttReferences:
<1992Aug10.200814.12809@ntmtv> <1992Aug11.133926.28840@actrix.gen.nz>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++ Path: arc1-ca.pugleaf.net!sparky!uunet!inmet!spock!stt From: stt@spock.camb.inmet.com (Tucker Taft) Subject: Re: Expanding enumerators in inheriting classes Message-ID: <1992Aug11.190816.8623@inmet.camb.inmet.com> Summary: Enumeration types less needed given type extension Keywords: inheritance, enumerator Sender: news@inmet.camb.inmet.com Nntp-Posting-Host: spock Organization: Intermetrics Inc, Cambridge MA References: <1992Aug10.200814.12809@ntmtv> <1992Aug11.133926.28840@actrix.gen.nz> Date: Tue, 11 Aug 1992 19:08:16 GMT Lines: 47