Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!spool.mu.edu!snorkelwacker.mit.edu!hsdndev!cmcl2!uupsi!srchtec.searchtech.com!johnb From: johnb@searchtech.com (John Baldwin) Newsgroups: comp.lang.c++ Subject: Re: asking an object for its type Message-ID: <1991Mar8.024331.14235@searchtech.com> Date: 8 Mar 91 02:43:31 GMT References: <71037@microsoft.UUCP> <27D57565.2B22@tct.uucp> <1991Mar7.153417.6489@linus.mitre.org> Organization: search technology, inc. Lines: 66 jimad@microsoft.UUCP (Jim ADCOCK) writes: ! C++ should actively support runtime type testing because the issue keeps ! coming up again and again and it takes great difficulty for individual ! applications to create it for themselves. chip@tct.uucp (Chip Salzenberg) responds: ! I most certainly would _not_ agree that dynamic typing needs to be ! added just because "the issue keeps coming up". Maybe lots of people ! are making similar errors. And dsr@mir.mitre.org (Douglas S. Rand) responds: ! This is not entirely correct. I am a previous CLOS/Lisp programmer and ! I viewed it as a mistake to query an object for its type. The correct ! paradigm is to allow the object system to disambiguate the types, ! that's what it's there for. . . . ! There is nothing which prevents a programmer from adding type testing ! to C++ classes now. Many real programs require some of this. (Begging your pardon, but that seems to be a contradiction. :-} ) Perhaps what we have here is in fact a needed extension to the language which, when not used judiciously, can be harmful. A good example in vanilla (ANSI) C might be the goto, or worse, setjmp() and longjmp(). [I know: they're part of the LIBRARY, not of the language itself. Consider, (A) The standard addresses them, and (B) All analogies break down at some level. :-/ ] Here's the real question: has anyone here needed type testing *for ANY other reason* than, 1) to implement persistent objects, or 2) to allow run-time object selection? If not, then maybe what we really need is simply language support for persistence. I *know* how painful it is to implement a cohesive and consistent object storage utility from scratch! Yes, when it was finished, we had something which was (more or less) optimized for our particular use, but there was no reason why the language or the library could not have provided efficient *standardized* support for this. On the other hand, if there are a sufficient number of other situations where dynamic type testing is needed, then what we need is not only that facility, but also a good understanding (in the form of widely known style rules) of the proper way to use it, and of improper uses to avoid. Both C and C++ are rife with constructs which, in the hands of a "spaghetti coder," can produce a real nightmare, but which, when used sparingly and judiciously by an experienced craftsman, can also result in efficient, structured, easy-to-read code. I guess before I can form an opinion or take a stand, I'd need to know which is the actual case: dynamic typing needed directly by the programmer, or just better support for persistence?? -- John Baldwin | johnb@searchtech.com Search Technology, Inc. | srchtec!johnb@gatech.edu Atlanta, Georgia | johnb%srchtec.uucp@mathcs.emory.edu