home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- 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
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Subject: Re: member test?
- Message-ID: <1992Nov13.212923.28600@ucc.su.OZ.AU>
- Sender: news@ucc.su.OZ.AU
- Nntp-Posting-Host: extro.ucc.su.oz.au
- Organization: MAXTAL P/L C/- University Computing Centre, Sydney
- References: <1992Nov6.081658.29693@bernina.ethz.ch> <EB.92Nov9085335@ascent.ascent.com> <1992Nov10.070124.5763@jyu.fi>
- Date: Fri, 13 Nov 1992 21:29:23 GMT
- Lines: 46
-
- In article <1992Nov10.070124.5763@jyu.fi> sakkinen@jyu.fi (Markku Sakkinen) writes:
- >In article <EB.92Nov9085335@ascent.ascent.com> eb@ascent.com (Ed Barton) writes:
- >>In article <1992Nov6.081658.29693@bernina.ethz.ch> haechler@bernina.ethz.ch (Stefan Haechler) writes:
- >>
- >> How can I know which dynamic type has a variable ?
- >> ...
- >> ...
- >>The software-design answer is that you shouldn't have to know the
- >>answer to this question, and that there may be something wrong with
- >>the design if you need to ask it. If you know only that something is
- >>a pointer-to-A, you should be using only the methods and virtual
- >>functions that are part of the interface defined by class A.
- >> ...
- >
- >Come on, there are many fully reasonable and legitimate situations
- >in which one needs to know this. And C++ is almost the only OOPL
- >I know of in which you cannot ask the dynamic type of an object.
- >
-
- In the single address-space standalone program model
- on which C++ is characterised it is never necessary to ask for
- the dynamic object type. That is, in a domestic program,
- one which creates all its objects itself, the program
- knows the type of the objects at construction time and is simply
- badly designed if the type information is lost when it is needed.
-
- A typical case, a list of objects of various types is often
- raised. It illustrates in my opinion a need for C++ to have better
- facilities for genericity such as tagged pointers, rather than
- unconstrained type testing. (See my tagged pointer proposal).
-
- The problem with asking an object its type IMHO is
- that one often deliberately loses this information.
- That purpose would be defeated if the information could be arbitrarily
- got back. In particular, if I have an Abstract Class A, and I have
- various implementations of A, so I construct A objects of various
- kinds, then I return pointers to A objects, I do NOT want anyone
- bypassing the Abstract Interface I have deliberately declared
- to restrict access to my objects.
-
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-