At 6:24 PM -0500 2/20/03, Mark Jason Dominus wrote:
Dan Sugalski <[EMAIL PROTECTED]>:
 At 2:06 PM +0000 2/19/03, Peter Haworth wrote:
 >On Fri, 14 Feb 2003 15:56:25 -0500, Dan Sugalski wrote:
 >>  I got clarification. The sequence is:
 >>
 >>  1) Search for method of the matching name in inheritance tree
 >>  2) if #1 fails, search for an AUTOLOAD
 >>  3) if #2 fails (or all AUTOLOADs give up) then do MM dispatch
 >
 >Shouldn't we be traversing the inheritance tree once, doing these three
 >steps at each node until one works, rather doing each step once for the
 >whole tree. MM dispatch probably complicates this, though.

 No, you have to do it multiple times. AUTOLOAD is a last-chance
 fallback, so it ought not be called until all other chances have
 failed.

Pardon me for coming in in the middle, but it seems to me that only one traversal should be necessary. The first traversal can accumulate a temporary linked list of AUTOLOAD subroutines. If the first traversal locates an appropriate method, the linked list is discarded. If no appropriate method is found, control is dispatched to the AUTOLOAD subroutine at the head of the list, if there is one; if the list is empty the MM dispatch is tried.

Fair enough--in practice we can do a single traversal, but conceptually we need to do multiple traversals. More importantly we can't check for method then AUTOLOAD then MMD in each class in turn up the hierarchy, which is what I think the original suggestion was. (Though I may have misinterpreted, of course)


If A isa B, we certainly wouldn't want to call A's AUTOLOAD on a method before we looked to see if B had a concrete instance of that method.
--
Dan


--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to