I just realized something that may be very important to my side of the
story.  It appears that I was skimming over your example when I should
have been playing closer attention:

On 7/18/05, Damian Conway <[EMAIL PROTECTED]> wrote:
> Consider the following classes:
> 
>        class A           {...}   #   A    B
>        class B           {...}   #        |
>        class C is B      {...}   #        C   D
>        class D           {...}   #         \ /
>        class E is C is D {...}   #          E
> 
>        multi sub foo(A $x, B $y) { "(1)" }
>        multi sub foo(A $x, C $y) { "(2)" }
> 
>        foo(A.new, E.new);
> 
> Clearly this produces "(2)" under either Pure Ordering or Manhattan Metric.
> 
> Now we change the class hierarchy, adding *zero* extra empty classes
> (which is surely an even stricter LSP/Meyer test-case than adding one
> extra empty class!)
> 
> We get this:
> 
>        class A           {...}   #   A      B
>        class B           {...}   #         / \
>        class C is B      {...}   #        C   D
>        class D is B      {...}   #         \ /
>        class E is C is D {...}   #          E
> 
>        multi sub foo(A $x, B $y) { "(1)" }
>        multi sub foo(A $x, C $y) { "(2)" }
> 
>        foo(A.new, E.new);
> 
> Manhattan Metric dispatch continues to produce "(2)", but Pure Ordering
> now breaks the program.

Ummmmm... no it doesn't.  Pure ordering continues to produce "(2)" as
well.  Here are the precise semantics of the algorithm again:

    A variant a is said to be _more specific than_ a variant b if:
        * Every type in a's signature is a subset (derived from or
equal) of the corresponding type in b's signature.
        * At least one of these is a proper subset (not an equality).
    A variant is dispatched if there is a unique most specific method
applicable to the given arguments. That is, there exists an applicable
variant a such that for all other applicable variants x, a is more
specific than x.

A is equal to A, and C is a proper subset of B, therefore the latter
variant is more specific than the former.  Since the latter is the
unique most specific variant, and it is applicable to the argument
types, it is chosen.

How did you think pure ordering worked?  Were we arguing over
different definitions of that algorithm?

Luke

Reply via email to