home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 16240 < prev    next >
Encoding:
Text File  |  1992-11-14  |  2.8 KB  |  59 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!munnari.oz.au!mel.dit.csiro.au!mineng.dmpe.CSIRO.AU!dmssyd.syd.dms.CSIRO.AU!metro!extro.ucc.su.OZ.AU!maxtal
  3. From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
  4. Subject: Re: member test?
  5. Message-ID: <1992Nov13.212923.28600@ucc.su.OZ.AU>
  6. Sender: news@ucc.su.OZ.AU
  7. Nntp-Posting-Host: extro.ucc.su.oz.au
  8. Organization: MAXTAL P/L C/- University Computing Centre, Sydney
  9. References: <1992Nov6.081658.29693@bernina.ethz.ch> <EB.92Nov9085335@ascent.ascent.com> <1992Nov10.070124.5763@jyu.fi>
  10. Date: Fri, 13 Nov 1992 21:29:23 GMT
  11. Lines: 46
  12.  
  13. In article <1992Nov10.070124.5763@jyu.fi> sakkinen@jyu.fi (Markku Sakkinen) writes:
  14. >In article <EB.92Nov9085335@ascent.ascent.com> eb@ascent.com (Ed Barton) writes:
  15. >>In article <1992Nov6.081658.29693@bernina.ethz.ch> haechler@bernina.ethz.ch (Stefan Haechler) writes:
  16. >>
  17. >>   How can I know which dynamic type has a variable ?
  18. >> ...
  19. >> ...
  20. >>The software-design answer is that you shouldn't have to know the
  21. >>answer to this question, and that there may be something wrong with
  22. >>the design if you need to ask it.  If you know only that something is
  23. >>a pointer-to-A, you should be using only the methods and virtual
  24. >>functions that are part of the interface defined by class A.
  25. >> ...
  26. >
  27. >Come on, there are many fully reasonable and legitimate situations
  28. >in which one needs to know this.  And C++ is almost the only OOPL
  29. >I know of in which you cannot ask the dynamic type of an object.
  30. >
  31.  
  32.     In the single address-space standalone program model
  33. on which C++ is characterised it is never necessary to ask for
  34. the dynamic object type. That is, in a domestic program,
  35. one which creates all its objects itself, the program
  36. knows the type of the objects at construction time and is simply
  37. badly designed if the type information is lost when it is needed.
  38.  
  39.     A typical case, a list of objects of various types is often
  40. raised. It illustrates in my opinion a need for C++ to have better
  41. facilities for genericity such as tagged pointers, rather than
  42. unconstrained type testing. (See my tagged pointer proposal).
  43.  
  44.     The problem with asking an object its type IMHO is
  45. that one often deliberately loses this information.
  46. That purpose would be defeated if the information could be arbitrarily
  47. got back. In particular, if I have an Abstract Class A, and I have
  48. various implementations of A, so I construct A objects of various
  49. kinds, then I return pointers to A objects, I do NOT want anyone
  50. bypassing the Abstract Interface I have deliberately declared
  51. to restrict access to my objects.
  52.  
  53.  
  54. -- 
  55. ;----------------------------------------------------------------------
  56.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  57.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  58. ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
  59.