home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / std / cplus / 1075 next >
Encoding:
Text File  |  1992-08-12  |  2.2 KB  |  47 lines

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!portal!ntmtv!hildum
  3. From: hildum@ntmtv.UUCP (Eric Hildum)
  4. Subject: Re: Expanding enumerators in inheriting classes
  5. Message-ID: <1992Aug12.192200.6873@ntmtv>
  6. Keywords: inheritance, enumerator
  7. Sender: hildum@ntmtv (Eric Hildum)
  8. Nntp-Posting-Host: ariel
  9. Organization: Northern Telecom Inc, Mountain View, CA
  10. References: <1992Aug10.200814.12809@ntmtv> <1992Aug11.133926.28840@actrix.gen.nz> <1992Aug11.190816.8623@inmet.camb.inmet.com>
  11. Date: Wed, 12 Aug 1992 19:22:00 GMT
  12. Lines: 33
  13.  
  14. In article <1992Aug11.190816.8623@inmet.camb.inmet.com>, stt@spock.camb.inmet.com (Tucker Taft) writes:
  15. |> 
  16. |> We considered supporting enumeration type extension in Ada 9X, but
  17. |> ultimately dropped it.  One issue (among others) was that values from distinct
  18. |> enumeration extensions of a parent enumeration type
  19. |> might have the same associated integer "code,"
  20. |> making direct comparison between them less meaningful.  That is, equality
  21. |> could be defined, but less-than/greater-than became relatively meaningfless.
  22.  
  23. Good point; however, C++ already allows duplicate codes, and it is not clear 
  24. why you would want (or would even be allowed to perform) comparisons between
  25. DISTINCT enumeration extensions. I supose you could do it by defining a friend
  26. function of both classes, in which case the meaning of such operations is up
  27. to the implementor of the classes.
  28.  
  29.  
  30. |> 
  31. |> One reason we lost interest was the observation that record 
  32. |> extension/derivation tends to make enumeration types less necessary.  
  33. |> Rather than having a variant record/union type with a value of an enumeration
  34. |> type distinguishing the variants, one would simply define distinct
  35. |> derivations.  A virtual function could return a string name
  36. |> for each distinct derivation, corresponding to the enumeration literal.
  37. |> A separate virtual function could return an integer code, if needed.
  38. |> 
  39.  
  40. That is run time type information via string compares, or via integer compares.
  41. The problem with this is that now the programmer has to be concerned with the
  42. exact values returned from each different class to prevent conflicts within
  43. inheritance trees (and across such trees), whereas with enumeration extension
  44. this could be done by the compilier automatically.
  45.  
  46.                 Eric
  47.