Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!husc6!rutgers!princeton!allegra!alice!bs From: bs@alice.UUCP Newsgroups: comp.lang.c++ Subject: Re: Questions About C++ Message-ID: <7017@alice.UUCP> Date: Tue, 23-Jun-87 20:03:42 EDT Article-I.D.: alice.7017 Posted: Tue Jun 23 20:03:42 1987 Date-Received: Thu, 25-Jun-87 04:26:58 EDT Organization: AT&T Bell Laboratories, Murray Hill NJ Lines: 60 Keywords: in - super - type checking - multiple inheritance It has been suggested in this series of articles that C++ lacks IN and SUPER. ``IN'' (and INSPECT) was deriberately not included (after much consideration of my experience with SIMULA) and can as pointed out can easily be provided by a programmer for a SPECIFIC tree of classes (either in a type secure and often reasonably efficient manner using a virtual function or in an optimally efficient and insecure manner using a cast). C++ certainly has an equivallent to the SMALLTALK ``SUPER'' (which SIMULA unfortunately lacks): class B { // ... public: virtual print() { cout << "B"; } }; class D : public B { // ... public: print() { cout << "D : "; // do my stuff B::print(); // let my base class B do its stuff } }; main() { D d; d.print(); B* p = &d; p->print(); } will print ``D : B'' twice. The reason that the notation ``name_of_base_class::'' is used rather than ``super'' is that this more explicit notation is general enough to cope with the needs of multiple inheritance (multiple base classes): class A { /* ... */ print(); }; class B { /* ... */ print(); }; class C : A, B { // ... print() { /* ... */ A::print(); B::print(); } }; It should also be noted that most or all of the features of a ``more dynamic'' i.e. dynamically, but not statically, typed language can be provided as a library in a statically typed language such as C++. Keith Gorlen's OOPS library demonstrates that dramatically by providing the most fundamental and useful non-graphical SMALLTALK classes for C++. (OOPS provides standard ``container classes'' such as dictonaries and sets, the ability to write an object to disk and read it back again, SMALLTALK-like Is and IsKindOf, etc.). The inverse operation, ``simulating'' a static type system for a language that posesses only dynamic type checking is much harder (e.g. it is a popular and very hard research problem to determine which part of a Smalltalk system is used by a specific program - and in which way - to ensure completeness and enable optimization).