On Fri, Jun 23, 2006 at 09:11:44PM +0300, Markus Laire wrote:
> 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?

Well, I think Num and Int *aren't* different types because as far as
duck typing goes, Num does Int.  I wouldn't expect that String does
Int though (at least not without some help :).

The way I see it, the types specified in the signature are like
constraints.   When you say

    sub foo (Num) { ... }

the signature says that "only an item that can perform the Num role may
fit in this slot". When perl tries to match Capture to Signature,
it checks the type of each argument in the Capture against the 
"does list" for each parameter in the Signature.  If the argument type
appears in the "does list" of the Signature, then it's a match and all
is well.  Otherwise it's an error.  Since "Num does Int", a call such
as C<foo(10);> succeeds.

At least that's my vague interpretation of this aspect of perl6 at
this moment.  :-)

-Scott
-- 
Jonathan Scott Duff
[EMAIL PROTECTED]

Reply via email to