I'm sending this also to perl6-language, in case someone there knows
an answer to this.

On 6/23/06, Jonathan Scott Duff <[EMAIL PROTECTED]> wrote:
I don't think so. I think the "best candidate" prose is about
choosing from types that have been specified, not autoconverting
between types such that one of them will match the long name. In
other words, when you have

    multi sub foo (Num) { ... }
    multi sub foo (Int) { ... }

    foo(1);
    foo("123");
    foo("bar");

foo(Int) is the best candidate for the first one because 1 is an Int.
But in the second and third calls, there is no "best candidate"
because strings were passed.  Would you expect the third call to
succeed because "bar" can be converted into the number 0?

I think you are right, but I don't see that mentioned anywhere in Synopses.

S12 clearly says that for a particular short name ("foo" here) *all*
visible long names ("foo(Num)" and "foo(Int)" here) are candidates and
best candidate *is* called (no matter how bad it is) -- unless there's
a tie.

So that would seem to say that for foo("123") above foo(Int) would be
called because it's the best candidate.

Which one is "better" for foo("bar")? foo(Int) or foo(Num)? Or is that a tie?

And what about other types?
e.g. if String can't ever be "best candidate" for Int, then does that
mean that neither can Int ever be "best candidate" for Num, because
they are different types?

The programmer put type information in the sig for a reason. I think
that reason is that they wanted to be careful about what was allowed
to be passed to the subroutine.  Autoconversion seems to defeat that.

-Scott
--
Jonathan Scott Duff
[EMAIL PROTECTED]


--
Markus Laire

Reply via email to