question about method dispatch

Stephen Pair spair at advantive.com
Fri May 10 20:06:14 UTC 2002


You just need to look at the Interpreter class.  The Squeak VM is mostly
written in Smalltalk and translated into C.  You are right that the
Squeak VM is not reflective enough to allow you to customize message
dispatch without building a new VM.  This is due to performance
optimization, as well as experimentation with previous versions of
Smalltalk that did allow some degree of this capability.  There has been
some discussion of allowing one to add a special method that, when
present, will receive all messages directed at an object (prior to any
lookup).  These types of things could certainly be handy when you're
trying to precisely replicate the protocol supported by some other
object (among other things).  
 
Conceivably, you wouldn't even necessarily need to restrict yourself to
traditional message selectors...for example, you could send an arbitrary
string of text to an object and let it figure out how to interpret it.
I think one of the old Smalltalks had this capability.  However, most of
the comments about it seemed to indicate that it led to a Tower of Babel
issue and didn't turn out to be as useful as originally thought.
 
- Stephen

-----Original Message-----
From: squeak-dev-admin at lists.squeakfoundation.org
[mailto:squeak-dev-admin at lists.squeakfoundation.org] On Behalf Of Jessie
Dedecker
Sent: Friday, May 10, 2002 3:02 PM
To: squeak-dev at lists.squeakfoundation.org
Subject: Re: question about method dispatch


Hello again,
 
thanks for replying so soon :)
 
I already took the optional of the #doesNotUnderstand: method into
account, however I would like to change the dispatch for <all> objects
and <all> messages, also existing ones.
But if I understood you correctly there is no way to change the dispatch
using the reflective capabilities of Smalltalk?  So I should start
looking at the C-code instead or did I understood it incorrectly?
 
Thanks,
 
Jessie Dedecker

----- Original Message ----- 
From: Stephen  <mailto:spair at advantive.com> Pair 
To: squeak-dev at lists.squeakfoundation.org 
Sent: Friday, May 10, 2002 3:46 PM
Subject: RE: question about method dispatch

If I understand your question correctly, you cannot change the method
dispatch algorithm in Squeak without modifying the VM.  However, you can
simulate a custom dispatch algorithm using the #doesNotUnderstand:
method.  That method gives you an instantiated message object and you
are free to interpret the message any way you like.  The downside is
that it's slower, and any actual methods implemented on your object will
mask the #doesNotUnderstand: method (#doesNotUnderstand: is sent
whenever the VM cannot find a method in the method dictionary (or a
superclass' method dictionary) that matches the selector).  The argument
is a reified version of the message that was sent, but not understood
(hence the name).  Have a look at Interpreter>>internalFindNewMethod
(and related methods) to see where the VM implements the dispatch
algorithm.
 
- Stephen

-----Original Message-----
From: squeak-dev-admin at lists.squeakfoundation.org
[mailto:squeak-dev-admin at lists.squeakfoundation.org] On Behalf Of Jessie
Dedecker
Sent: Friday, May 10, 2002 2:36 PM
To: squeak-dev at lists.squeakfoundation.org
Subject: question about method dispatch


Hello,
 
could anyone please tell me how I can change the method dispatch in
smalltalk.  I tried to change the ContextPart>>send:super:numArgs: but I
guess
this doesn't work because of optimisations that were performed.
 
Is there a way to change the dispatch?
 
Thanks,
 
Jessie Dedecker

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20020510/f2d2ef6d/attachment.htm


More information about the Squeak-dev mailing list