Newsgroups: comp.lang.c++ Path: utzoo!utgpu!craig From: craig@gpu.utcs.utoronto.ca (Craig Hubley) Subject: Re: asking an object for its type Message-ID: <1991Feb22.194649.13381@gpu.utcs.utoronto.ca> Organization: Craig Hubley & Associates References: <23984@netcom.COM> <1190@sheol.UUCP> <1991Feb19.000449.22255@gpu.utcs.utoronto.ca> <27C2D580.3B49@tct.uucp> Date: Fri, 22 Feb 1991 19:46:49 GMT In article <27C2D580.3B49@tct.uucp> chip@tct.uucp (Chip Salzenberg) writes: >According to craig@gpu.utcs.utoronto.ca (Craig Hubley): >>But in more intelligent O-O languages, asking the type, or better, >>asking if there is a diameter, is a fundamental operation in type >>Object that all objects can do. > >"More intelligent"? Your prejudices are showing. :-) Other languages support a syntax with fewer seams, and resolve efficiency issues with an optimizer. C++ deliberately doesn't do this and leaves it in the hands of the programmer, therefore C++ as a language decides that it will be less intelligent and force programmers to be more intelligent. Although this may be a compliment to C++ programmers, it is also more work for them, and it may be unnecessary in some places. I didn't really think of this as a prejudice, just a statement of fact. >C++ is statically typed. And there is no requirement that all classes >be derived from a hypthetical Object class. So the features you desire >cannot be accomplished in C++. Nonsense. There is absolutely no reason that the compiler cannot determine that *circle* has a diameter at compile-time, indeed it MUST know that. A macro/function/who-cares like x.has_member(diameter) can be completely optimized away at runtime where the type is unambiguous. Where it is ambiguous, the cost is exactly the same as a virtual function which was your alternate solution, but one which would require me to change the base class shape, which is unacceptable. >BTW, I happen to find C++ an excellent tool for _exactly_ those >reasons. I pay only for those OOP features I need, and no more. Nobody is suggesting a compromise to this principle. >Chip Salzenberg at Teltronics/TCT , -- Craig Hubley "...get rid of a man as soon as he thinks himself an expert." Craig Hubley & Associates------------------------------------Henry Ford Sr. craig@gpu.utcs.Utoronto.CA UUNET!utai!utgpu!craig craig@utorgpu.BITNET craig@gpu.utcs.toronto.EDU {allegra,bnr-vpa,decvax}!utcsri!utgpu!craig