|
From: Manuel T. <ma...@sp...> - 2000-12-18 20:05:09
|
Hi Clemens
> Or perhaps something like (on:do:) matches all on:do:'s regardless how
> often it occurs. That means, if my selector is named
>
> on:do:(or-on:do:)
>
> it would match all on:do:or-on:do:, on:do:or-on:do:or-on:do:... and
> so on. The parameters for the part of the selector in parenthese
> could be passed as lists. So it would look like this:
>
> ... method: :on:do:(or-on:do:) is: { |p1 p2 list1 list2| ... }
Sorry, I misread your actual proposal about this, so here is an amendment to my last reply.
A small problem with this is that when you are sending a message there is no way to tell between
a normal method and a 'variable-length' one as defined in your proposal.
So if you have
foo me: ... you: ... me: ... you: ... me: .. you: ...
then the compiler will generate code sending the method: me:you:me:you:me:you: to
the receiver foo. Normally the evaluator will lookup that symbol and if not found give
and error.
But if we had such variable methods, then after the initial failure the evaluator would
have to see if the receiver (and it's parents) have any variable methods, and then
generate strings that are possible matches and do some string comparisons for each of these
to try to find a match. This could be a bit slow (but of course these variable methods would not
be so common, so if we really need this we could do it, and my solution isn't exactly that fast,
maybe we could even find a faster imlpementation that the one I just mentioned).
But I prefer the Scope style solution (and the Handler one proposed in my last mail)
for such problems, because it kind of feels a bit more clean and more 'Object-Oriented'.
One advantage of my solution is that you can interleave different kinds of calls like:
Foobar
on: ... do:...;
on: ... do: ...;
whatever: .. do: ...;
on: ... do: ..;
ensure: ...;
something: ...;
....
But if we find any problem that can only be solved in a way such as
the one you propose, then we will have an idea to implement.
Manuel
|