On Thu, Jun 05, 2008 at 10:45:08PM +0200, Moritz Lenz wrote:
> > 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?  
> 
> We can't, because the subroutine call takes the invocant as the first
> positional argument. If it should fall back (and I don't know if it
> does), you have to declare sub bar(Foo $w, Int $x){ say "sub bar" }

You're correct, my examples suck today.  Sorry about that.

The "I don't know if it does" part of your answer is the crux of my 
question.  Essentially, does having _any_ 'bar' multimethod in a 
class automatically suppress a fall back to a subroutine call,
even if none of the multimethods' signatures match?

Pm

Reply via email to