http://qs321.pair.com?node_id=913101


in reply to Re: Workings of UNIVERSAL::can
in thread Workings of UNIVERSAL::can

The algorithm is a simple symbol table search in method resolution order.

Hi :D

Actually :) Method resolution order is not an algorithm (or an actual order) or any more than symbol table search is an algorithm.

Or put another way, a sort-algorithm is not an actual algorithm, but a bubble-sort-algorithm is an sort-algorithm; is an algorithm.

Perl's default method-resolution-order, algorithm , is a linear-depth-first-search.

You can change that in modern perls with the mro pragma to C3 linearization

Replies are listed 'Best First'.
Re^3: Workings of UNIVERSAL::can
by Somni (Friar) on Jul 07, 2011 at 00:12 UTC
    The fact that mro is changeable is why I said method resolution order, and not a specific order.

    Taken individually, each of the items is not an algorithm. Taken together (symbol table search in method resolution order), it is an algorithm, though ill-specified due to the variable of which mro is in effect.

      Taken individually, each of the items is not an algorithm. Taken together (symbol table search in method resolution order), it is an algorithm, though ill-specified due to the variable of which mro is in effect.

      No, taken together, it is still not an algorithm. An algorithm is well-defined by definition.

      Also, its just repeating the question back at the original poster. The answer might work for "how do I print $foo?" (well, you print $foo;), but not here.