Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!osu-cis!killer!texbell!sw1e!uucibg From: uucibg@sw1e.UUCP (3929]) Newsgroups: comp.lang.c++ Subject: Re: Smalltalk-80 like inheritance in C++ possible ? Message-ID: <1411@sw1e.UUCP> Date: 23 Mar 89 14:19:25 GMT References: <110@honold.UUCP> <5481@rlvd.UUCP> Reply-To: uucibg@sw1e.UUCP (Brian Gilstrap [5-3929]) Organization: Southwestern Bell Telephone Co Lines: 37 In article <5481@rlvd.UUCP> cmc@inf.rl.ac.uk (Chris Crampton) writes: >In article <110@honold.UUCP> franco@honold.UUCP (Franco Monti) writes: >> How can I translate the behavior of >> the code outline [below] to the appropiate structures in C++ ? > [A very good translation from some Smalltalk code to some C++ code] >Hope this answers your question. Just a quick note: While it may be possible to port large portions of many classes from Smalltalk-like languages to C++, there are some definite problems. The biggie is of course the fact that C++ uses strong typing of objects (e.g. determine at compile time what function/method is to be invoked ) while Smalltalk and Smalltalk-like languages use weak typing of objects and actually accomplish function address resolution at run-time. The net result of this is that in Smalltalk-like languages you can try to invoke any method of (send any message to/ invoke any member function of) any object. If the object's class doesn't implment the method (message/function) then the method (function/ essage) resolution code will detect such a condition. The resolution code will then often invoke the object's "error" method (send the error message/invoke the error function). In a nutshell: In Smalltalk-like languages, class references (refs to objects) are not typed and you can send them any message you want to. In C++-like languages (or Eiffel-like languages, etc.), references to objects are typed and you can only send a message to an object (invoke an object's function) if the object's class definition included mention of that message (method, function). I'd be interested to discuss the plusses/minuses of each approach here or in comp.misc or comp.compilers or where ever seems appropriate. But please, no flames, though corrections would be appreciated. Brian R. Gilstrap Southwestern Bell Telephone One Bell Center Rm 17-G-4 ...!ames!killer!texbell!sw1e!uucibg St. Louis, MO 63101 ...!bellcore!texbell!sw1e!uucibg (314) 235-3929 #include