develooper Front page | perl.perl6.language | Postings from March 2005

Re: MMD as an object.

Thread Previous
Thomas Sandlaß
March 9, 2005 09:21
Re: MMD as an object.
Message ID:
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 = $";

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

my $obj =;

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.

TSa (Thomas Sandlaß)

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About