Messaging vs. subroutines

Joachim Durchholz joachim.durchholz at munich.netsurf.de
Mon May 17 08:25:28 UTC 1999


jecel at lsi.usp.br wrote:
> 
> I think it would be fair to say that Joachim examined the source code
> for the Squeak VM and found the messages were IMPLEMENTED AS
> subroutines. That is not the same as saying messages ARE subroutines.

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.

> To use the example by Randal L. Schwartz: if you look at the bytecodes
> generated by the compiler for #whileTrue: or #ifTrue: you might
> conclude that blocks ARE the same thing as blocks in Algol or Pascal.

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. Examining the
VM to find out how messages are passed reveals how message passing is
done in every case.

> Even as it is today, if you look at things like #perform: or proxies
> using "message not understood" you can see that subroutines don't
> fully explain what is going on (sorry if I got these selectors wrong
> - I have been programming mostly in Self, lately).

#perform: isn't very special. It's just the same as (eval ...) in Lisp.
But nobody ever claimed that subroutine calls should be named
differently in Lisp.
A similar thing goes for proxies. It would be easy to beef up, say,
Basic to include an OnUnknownSubroutine handler. It would require some
library stuff to give that handler enough information so that it can
reissue the call in the appropriate context, but nothing of this is
particular to Smalltalk or messaging.

Regards,
Joachim
-- 
Please don't send unsolicited ads.





More information about the Squeak-dev mailing list