[ANN] MessageCapture

Josh Gargus schwa at fastmail.us
Mon Oct 16 10:07:26 UTC 2006

On Oct 16, 2006, at 4:32 AM, Michael van der Gulik wrote:

> Bert Freudenberg wrote:
>> Am 15.10.2006 um 08:56 schrieb Michael van der Gulik:
>>> I've been using a class called "MessageCapture" which lets you   
>>> receive messages sent to an object. It's caused me no end of  
>>> agony  trying to get it working, so I thought I'd share my agony  
>>> with the  community :-P.
>>> Source code here: http://www.squeaksource.com/DPON.html - click  
>>> on  "latest", MessageCapture-mvdg.2.mcz.
>>> It's released under the.. umm... MIT license.
>>> Also included is a Future class, which lets you do things like:
>>> result := Future doing: [ some long computation ].
>>> This will return immediately, forking off a process to do the   
>>> computation and replacing "result" with the result when it's  
>>> finished.
>>> Some of the tests fail. Any hints / tips / guidance is very   
>>> welcome! Especially as to how to capture #== and #class. Those  
>>> two  messages are sent by the interpreter even before doing a  
>>> message  lookup.
>> You might want to look at how this is handled in Croquet (MIT   
>> licensed, too). As you know (or maybe not) Croquet is not  
>> foremost  about 3D but about distributed computing with capability- 
>> based  security. The messaging infrastructure with future sends,  
>> returned  promises etc. is independent of the UI.
>> Now the current implementation does not yet provide water-tight   
>> security, but the principles are there and it's surely worth  
>> having a  look.
> Correct me if I'm wrong, but I think Croquet uses pretty normal  
> objects for what it does. Objects are grouped together, and inter- 
> group references are done using FarRef objects.

That's correct.  Croquet also has a notion of "future", but unlike  
your Future example above, there is no immediately-returned  
placeholder that is later replaced (via #become: ?) by the real value  
when it becomes known.  Instead, the immediately-returned value is  
another FarRef.  To determine whether the computation has finished,  
you can ask it #isResolved, or you can use 'aFarRef wait' to block  
until the FarRef is resolved.


> I think it completely avoids the problem of capturing references -  
> arguably a more stable approach than what I'm doing.
> Can anybody confirm this?
> I'm aware that Spoon and Magma also do message capture. I like  
> Spoon's approach best: modify the VM.
> Michael.

More information about the Squeak-dev mailing list