multicasting (was: idea: slices)

Rainer Blome rainer at
Thu Jun 13 10:43:09 UTC 1996

Jecel wrote:
> Rainer Blome wrote:
> > I was looking for a way to allow `selection do: [moveBy: distance. ]'.
> > ... Am I missing something ...?
> Blocks are lexically scoped, so the receiver of the moveBy:
> message will be the receiver of the method that executes this
> expression ...

That's why I said that `I was looking for a way to allow ...'.
After sending my last message, it occurred to me that I wanted
`moveBy:' to be sent to the selection member, and `distance' to the
implicit self that sends `do:'.  So it'll never work like that.

Either way, distance is a message to the sending context.  How
often is it supposed to be sent?  Once for each element of the
selection?  Imagine this in a distributed environment.

In my view, the main advantage of `blocks as messages' is better
locality.  Evaluation of the block (at least conceptually) happens
at the elements' sites, the selection is not involved any more.
With the `:value' method, it is the selection or the owner of the
block who conceptually does the work.

A mechanism to initialize a block's slots with locally computed
values would be useful.  Is there a way to package the result of
sending `distance' in such a way that it is local to the block
being sent?  (I'm not sure whether I am expressing myself clearly

To do this in Self, one has to pack up all that is needed in a
throwaway object, then pass it to the block given to `do:' along
with the element (this probably has the usual glitches):

  (| proxy= (| parent* = traits clonable.
               distance <- nil.
	       speed <- nil. |). |
   proxy distance: distance.
   proxy speed: speed.
   selection do: [| :element.  :proxy.  environment* <- nil. |
		  environment*: proxy clone.  -- Now we have local references
		  element moveBy: distance With: speed.
		  ] With: proxy.

This looks awkward.  But the block is free of free variables
now, so we can repackage this.  The do:With: method could decorate the user
code (the last line) with what is needed to get the above behavior.

  selection _define do: action With: proxy
  (do: [| :element.  environment* <- nil. |
	environment*: proxy clone.  -- Now we have local references
	-- problem: how to eval action in this context here
	action value: element.

Then a call could look like

  selection do: [|:element| element moveBy: distance With: speed]
	    With: "distance: distance.  speed: speed.  " makeObjectHere,

where `makeObjectHere' creates the proxy.

This is getting lengthy, enough of this for now.


More information about the Self-interest mailing list