On Wed, Aug 29, 2001 at 10:49:25PM -0700, Hong Zhang wrote:
> What is the need for CLOS? Are we trying to build a kitchen
> sink here?
Umm, I think you mean "What's the need for multiple dispatch?"
Currently, if I want to write a method that does this:
my $name = $foo->name;
$foo->name($name);
I have to write:
sub name {
my($self) = shift;
if( @_ ) {
my $name = shift;
$self->{name} = $name;
}
return $self->{name};
}
With multiple dispatch, I could instead write:
# Following RFC 256
sub name (Foo $self) : multi {
return $self->{name};
}
sub name (Foo $self, STRING $name) : multi {
$self->{name} = $name;
return $self->{name};
}
which is quite a bit simpler.
--
Michael G. Schwern <[EMAIL PROTECTED]> http://www.pobox.com/~schwern/
Perl6 Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One
My lips, your breast and a whole lotta strange arguing.