Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!tut.cis.ohio-state.edu!att!cbnewsc!jwd From: jwd@cbnewsc.ATT.COM (joseph.w.davison) Newsgroups: comp.object Subject: Re: "Messaging" (Re: Reentrant code) Message-ID: <4115@cbnewsc.ATT.COM> Date: 26 Oct 89 20:06:56 GMT References: <135300010@p.cs.uiuc.edu> Reply-To: jwd@cbnewsc.ATT.COM (joseph.w.davison,55515,ih,6n503,312 979 4920) Organization: AT&T Bell Laboratories Lines: 34 In article <135300010@p.cs.uiuc.edu> johnson@p.cs.uiuc.edu writes: > > >I said >>> There is no essential difference between Smalltalk messages and C++ >>> virtual functions. > ... >The big advantage of Smalltalk untyped messaging is that it is much >better suited to experimental programming. Virtual functions are >closely tied to C++'s type system, which forces the programmer to >decide interfaces early. When the interfaces turn out to be wrong, >as usually happens, the programmer has to make lots of revisions. >However, from a high-level design point of view, I don't think that >there is much difference between them. > Basically, I agree, C++ virtual functions are pretty much the same as Smalltalk messages. However, one cannot escape the static typing/ dynamic typing distinction. The first time I came to see the big difference between C++ and Smalltalk was when I tried to implement ComplexNumber. In Smalltalk, when I operated on a ComplexNumber and the result had a 0 imaginary component, I returned only the real component, whatever type it was. That works nicely, to simplify many methods, and is similar to the way I use complex numbers. When I tried to write ComplexNumber::operator+(...) in C++, it became very clear what the difference was. Static typing not only forces early decisions about interfaces, it also precludes some approaches to problems. Some people think that's an asset; I tend to think some of the decisions it forces early are better made later. -- Joe Davison jwd@ihlts.att.com