On Thu, Jun 05, 2008 at 05:29:25PM +0100, Daniel Ruoso wrote:
> Qui, 2008-06-05 às 11:04 -0500, Patrick R. Michaud escreveu:
> > Does fall back to a subroutine occur anytime we don't have
> > a method with a matching signature?  For example, if we have
> 
> as far as I understand it, it only falls back to sub-dispach if the
> method dispatch would otherwise fail, which basically means...
> 
> >     class Foo {
> >         multi method bar(Num $x) { say "Foo::bar"; }
> >     }
> >     sub bar(Int $x) { say "sub bar"; }
> >     my $foo = Foo.new;
> >     $foo.bar(3);
> 
> since Num.ACCEPTS(3) should return true (rakudo is failing that), the
> method dispatching should be successfull, therefore no fallback occurs.

Okay, so my bad example didn't provide an answer to my
original question.  Let's try it this way:

    class Foo {
        multi method bar(Dog $x) { say "Foo::bar"; }
    }
    sub bar(Int $x) { say "sub bar"; }

    my $foo = Foo.new;
    $foo.bar(3);

In this case, since Foo has a bar method (but not one matching Int), 
do we still fall back to the subroutine call?  How about if the method 
isn't a multimethod (or if the sub is a multisub)? 

Pm

Reply via email to