home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c++:11240 comp.std.c++:899
- Newsgroups: comp.lang.c++,comp.std.c++
- Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Subject: Re: run-time type checking (was: Re: Covariant Types in Derived Classes)
- Message-ID: <1992Jul21.162659.25474@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: <1992Jul20.143900.23087@merlin.hgc.edu> <1992Jul20.215058.1216@cadsun.corp.mot.com>
- Date: Tue, 21 Jul 1992 16:26:59 GMT
- Lines: 57
-
- In article <1992Jul20.215058.1216@cadsun.corp.mot.com> shang@corp.mot.com writes:
- >Secondly, we both
- >agree that it is necessary to allow rediscovery of a type.
-
- In general C++ programming I do not agree that it is
- necessary to recover arbitrary type information. That is because,
- quite simply, you CANNOT use it.
-
- >What I disagree is
- >the argument that the design of heterogeneous collection is fundamentally
- >wrong, which, of cause, is not your statement.
-
- I think I should clarify here: I am arguing against
- DOWNCASTING.
-
- I am not against collections of objects all derived
- from a common base provided you access them via the base.
- That is the vey point of inheritance, after all.
- In this case the objects are all of the same type:
- it is homogeneous at the level it is accessed and
- heterogeneous at the actual object level, but the actual
- object level is not accessible.
-
- I am not against collections of objects of completely
- unrelated types provided the types are drawn from a finite
- and statically known set. In this case there is a 'type' which
- is the finite union of those types, so again, the collection
- is really homogeneous wrt that type.
-
- I am not against the two above combined either.
-
- I am against using, in general programming,
- DOWNCASTING or run-time type information to defeat the type system.
-
- I agree that in Debuggers and other such programs
- these facilities are essential, indeed, you need much more
- than a mere safe downcast or run-time type code. In a debugger,
- for example, you need in effect run-time access
- to the complete declaration and definintion of each class in
- the whole program!
-
- C++ does NOT have facilities at present to do this.
- I am NOT against adding them. But I would be against using these
- facilities in the general programming context for which C++
- was intended and where such mechanism are *dangerous*.
-
- Clearly, for example, a debugger which allows you
- to modify instances of a class breaks encapsulation!
- It breaks almost every principle you can think of.
- It is meant to: you use the debugger when a more important
- thing is already broken : your program :-)
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-