Messaging vs. subroutines

agree at carltonfields.com agree at carltonfields.com
Mon May 17 16:47:08 UTC 1999


> Fully agreed. But once I had seen that they were implemented as
> subroutines, I didn't see anything that made them more special than
> subroutines. Well, with one exception, of course: dynamic dispatch is
> novel, but not novel enough to declare that message passing is totally
> different from subroutine calls.

It is one thing to say that messaging is "totally different" from subroutine calls, it is another to say that message passing is "exactly the same" as subroutine calls.  I should hope, at least by now, that we can all agree that the truth is rather more interesting than either of these postures.

Clearly the disproving of one does not demonstrate the other, and this is my point.  Conceded that one can be implemented in terms of the other.  So what?  C++ was originally written as a compiler with C as the object code.  Does this mean that OO is "exactly the same" as routine imperative programming?

Isn't it possible that one thing can be "different from" another without being "totally different from" the other, at least in the fuzzy sense those terms are being used in this discussion?


> No. The internals are quite different. Besides, the parallel doesn't
> hold: looking at the bytecodes for #ifTrue: shows that blocks are the
> same as Algol blocks within the context of #ifTrue: only. 

This is kinda' silly.  The code for the #ifTrue: methods are these:

	True>>ifTrue: trueAlternativeBlock
		^ trueAlternativeBlock value

and

	False>>ifTrue: trueAlternativeBlock
		^ nil

Explain that (simply) as a procedure call using only Algol semantics!  Explain this to a programmer in the context of, "message sends are just procedure calls with an additional selection thingie first."

The point here is that the "selection thingie" *is* the semantic functionality of the message send.

Arguing that these are the same is almost like asserting that the code for computing the truth of, say, the Goldbach conjecture or the halting problem can be written quite efficiently and easily as follows: code up two procedures:

	A>>Goldbach() { printf ("The conjecture is true\n") }

	B>>Goldbach() { printf ("The conjecture is false\n") }

with just a little "selection thingie."

Of course, the halting problem scenario is impossible, and the Goldbach selection thingie is unknown, while the class selection thingie is far more concrete.  This does not mean that these programming paradigms are "exactly the same as" or even "the same as" coding with procedures.

As Joachim noted, double dispatch and the implementation of #ifTrue: are fairly unique to Smalltalk and its progeny.

> Examining the
> VM to find out how messages are passed reveals how message passing is
> done in every case.

A point has been made countless times in response to the countless repetitions of this argument in various forms.  How does the implementability in terms of functions make messaging "the same as" functions?

At some point, this has to come to an end.  None of the issues being raised here seem to be joined by the arguments.  Perhaps it is time simply for Joachim and I to agree to disagree? 





More information about the Squeak-dev mailing list