Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!think.com!linus!linus!mir!dsr From: dsr@mir.mitre.org (Douglas S. Rand) Newsgroups: comp.lang.c++ Subject: Re: asking an object for its type Message-ID: <1991Mar7.153417.6489@linus.mitre.org> Date: 7 Mar 91 15:34:17 GMT References: <1991Feb20.232710.7843@ithaca.uucp> <1485@acf5.NYU.EDU> <71037@microsoft.UUCP> <27D57565.2B22@tct.uucp> Sender: news@linus.mitre.org (News Service) Reply-To: dsr@mir.mitre.org (Douglas S. Rand) Organization: The MITRE Corporation Lines: 57 Nntp-Posting-Host: mir.mitre.org In article <27D57565.2B22@tct.uucp>, chip@tct.uucp (Chip Salzenberg) writes: > According to jimad@microsoft.UUCP (Jim ADCOCK): > >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. > > 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. > > Lots of Smalltalk, Objective C, CLOS, etc. programmers are converting > to C++, and they are looking for language features like those of their > previous languages so they can keep programming in the ways to which > they are accustomed. This fact is not surprising. > 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. IMHO you are not getting the requests from SmallTalk et al but from naive C programmers who have never programmed using an OOP language before. This is a standard trap for new OOP programmers. > What they do not realize, however, is that C++ programming does not > always admit of Smalltalk/Objective C/CLOS/etc. strategy. Some of > them eventually get a clue. Many, however, never give up in trying to > force the square C++ peg into the round dynamic-type-test hole. > C++ strategy *is* Smalltalk/CLOS/Flavors strategy. The only difference is the richness of the environment. C++ is not a dynamic environment for most people (ParcPlace C++ is at least one counterexample), but the programming practice is basically similar. > >The implication being that run-time type testing requires an interpreter- > >like approach, or that adding run-time type testing turns C++ into > >a Smalltalk or a CLOS. I disagree. > > It would not transform C++ into Smalltalk, true. But it would be a > move in that direction, a move which is, in my opinion, entirely > unnecessary. > There is nothing which prevents a programmer from adding type testing to C++ classes now. Many real programs require some of this. You can add instance fields which get named in constructors, virtual functions which return values, all kinds of perfectly acceptable options are available to the programmer. -- Douglas S. Rand Internet: Snail: MITRE, Burlington Road, Bedford, MA Disclaimer: MITRE might agree with me - then again... Amateur Radio: KC1KJ