Trampolines (was: Re: (1 to: self) inject: 1 into: #*)

Andrew P. Black apb at cse.ogi.edu
Thu Feb 3 20:39:14 UTC 2000


At 23:29 +0100 2000.01.19, Marcel Weiher wrote:
>
>[Nice comments about trampolines]  Thanks ! (blush)

There have been some interesting comments in this thread about 
trampolines.  This is a term that I have heard used, but I'm not sure 
exactly what it means. I wonder if Marcel or someone else could 
enlighten me (and others)?

For example, what is going on in

>So, the way to multiply an array by 2 using standard trampoline-like
>messaging would be
>
>	#(1 2 3 4 5) collect * 2.

I'm guessing that #collect on an array returns a "trampoline" object 
with a reference to the specific array, and then this trampoline 
understands * and implements it by sending collect: [ :each | each * 
arg ] to that array.

But how is this implemented?  Something more clever than one method 
in the trampoline for each arithmetic operator, I presume!

As another example,  on 18:36 -0500 2000.01.19, Stephen Pair wrote:
>I found the trampoline concept very useful...Marcel actually modified some
>asynchronous message code of mine to use his trampoline stuff.  The original
>code was written like:
>
>anObject asend: #message with: arg
>
>...which was kind of cumbersome.  With the trampoline, it simply became:
>
>anObject asend message: arg.
>
>...beautiful!

A agree, and I'm guessing that here the "trampoline" returned by 
(anObject asend) implements message: arg by doing something like

	[myObject message: arg] fork

but, once again, I would like to see how this is implemented in a general way.

Incidentally, Marcel, I did look at your DiplomaThesis, and found it 
very interesting.  It's a very nice survey of some things that I knew 
about and many others that I did not.







More information about the Squeak-dev mailing list