Luke Palmer wrote:
Keep in mind that the two following definitions are equivalent:

    class A { method foo () {...} }
    multi sub foo (A $a) {...}

Except for attribute access, I think. For public attrs the accessor is not used and private ones are available:

class A
{
   has $.pub = "pub";
   has $:priv = "priv";
   method foo ()
   {
      say "pub = $.pub";
      say "priv = $:priv";
   }
}

multi sub foo( A $a )
{
   say "pub = $a.pub()";
}

Another subtlety is that the method call syntax prefers single dispatch:

my $obj = A.new;

$obj.foo();
foo( $obj );


I think stuffing a method into a multi sub should be just fine.

Me too. The above is irrelevant for the call site.

MfG
--
TSa (Thomas SandlaÃ)




Reply via email to