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.