[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

multicasting (was: idea: slices)



Rainer Blome wrote:
> Currently, if I understand correctly, you have to write sth. like
> 
>            selection do: [|value| value moveBy: distance.  ].

Right, except it should be ...[|:value| value... as you
are declaring an argument slot.
 
> I was looking for a way to allow
> 
>            selection do: [moveBy: distance.  ].
> 
> For this to work, global behavior would have to include a way to
> accept and process such a block (either by a `do:' message or, even
> cooler, by directly accepting blocks as messages).  Am I missing
> something (again)?

Blocks are lexically scoped, so the receiver of the moveBy:
message will be the receiver of the method that executes this
expression (or the lobby (actually shell), if typed at the
prompt).

I think you would be happier with

            selection all moveBy: distance.

where "selection all" returns a special multicasting proxy for
the selection's elements. If the selection itself were this
proxy, then the "all" could be omitted, but other things would
become awkward (but maybe you could use mirrors to handle them).

This kind of thing might make certain parts of the user
interface more elegant (see how you register for receiving
step messages or mouse messages), but I don't think it is worth
the effort. I did include this feature in the Troy language
I designed some time ago (I called them groups), but now I
think selection do: [] is good enough.

-- Jecel