More on the tutorial...
nicolas.pelletier3 at free.fr
nicolas.pelletier3 at free.fr
Tue Oct 12 22:59:33 PDT 2004
Pupeno <pupeno at pupeno.com> writes:
> In http://perso.wanadoo.fr/kodama/x265.html it says:
> "The method executed is the "most specific" method that has the signature
> #aimAt:with: and applies to archer: if we call delegation distance the number
> of arcs in the graph of delegates for archer, then the method that is
> executed has the shortest delegation distance among all methods that could
> apply."
> And shows this image http://perso.wanadoo.fr/kodama/depth-first.gif
> The numbers 1, 2, 3, 4 show the priority of the method, right ? But according
> to that statment, if the method is found for 3 and 4, 4 should be used
> because the arc is shorter (only one hop while the arc of 3 is two hops). I
> think this is only a problem in the picture, or, I may have missunderstood
> some concepts. Can anybody clarify and see if the tutorial needs correction ?
> Thanks.
The purpose of this picture is just to show that the lookup for roles
is a depth first search (as is written just above it). The numbers 1,
2, 3, 4 show in which order the objects are queried for roles. First
the roles are collected (and there is no notion of delegation distance
a priori in this phase). Then, they are sorted (and this is where
delegation distance comes into play).
Do not forget that what the dispatch algorithm is really looking for
is roles (not directly methods). From the set of roles resulting from
the search and the sort, it tries to select a method. You may think of
a role as a tuple (position in the call, signature of the call).
In the current implementation (src/mobius/vm/base/dispatch.slate), an
object has a map, the map has a table of roles, and a role references
a method definition.
--
Nicolas
More information about the Slate
mailing list