Re: A6: overloading multis on constness of parameters

2003-03-14 Thread Larry Wall
On Fri, Mar 14, 2003 at 01:45:56PM +1100, Damian Conway wrote: : Oh, and I was wrong to originally write: Cmulti *isa ... Sorry, you're not even wrong. :-) : Multimethods live in their own namespace. No * required. Alternately, we require the C* in order to accurately document their scope.

Re: A6: overloading multis on constness of parameters

2003-03-13 Thread Damian Conway
Piers Cawley wrote: Speaking of multis and constants, Greg McCarroll wondered on IRC if this would work: multi factorial (Int 0) { 1 } multi factorial (Int $n) { $n * factorial($n-1) } Probably not. We did discuss whether multimethods should be able to be overloaded by value, but

Re: A6: overloading multis on constness of parameters

2003-03-13 Thread Luke Palmer
or, supposing we have some form of parameterized types, you could create something more generic like: class Val($N) { multi *isa ($obj, Val($N) $class) { $obj ~~ $N } } # and then... multi factorial (IntVal(0) $g) { 1 } Yes, YES! Marvelous! Not

Re: A6: overloading multis on constness of parameters

2003-03-13 Thread Damian Conway
Luke Palmer wrote: Not that that couldn't be done with a closure anyway... { my Class %valClasses; sub Val($N) returns Class { my Class $rclass = %valClasses{$N} //= class { multi *isa ($obj, $rclass $class) { $obj ~~ $N } } } } multi

Re: A6: overloading multis on constness of parameters

2003-03-12 Thread Larry Wall
On Wed, Mar 12, 2003 at 01:35:08PM +1100, Damian Conway wrote: : Joe Gottman wrote: : :Will it be possible in perl6 to overload multis on the const-ness of a : parameter, like C++ does? For instance, : :multi getX(Foo $self:) returns Int {...} #const version :multi getX(Foo $self:

Re: A6: overloading multis on constness of parameters

2003-03-12 Thread Piers Cawley
Joe Gottman [EMAIL PROTECTED] writes: Will it be possible in perl6 to overload multis on the const-ness of a parameter, like C++ does? For instance, multi getX(Foo $self:) returns Int {...} #const version multi getX(Foo $self: is rw) returns Int is rw {...} #non-const version

Re: A6: overloading multis on constness of parameters

2003-03-12 Thread Joe Gottman
- Original Message - From: Damian Conway [EMAIL PROTECTED] To: Perl6 [EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 9:35 PM Subject: Re: A6: overloading multis on constness of parameters Joe Gottman wrote: Will it be possible in perl6 to overload multis on the const-ness

Re: A6: overloading multis on constness of parameters

2003-03-12 Thread Luke Palmer
- Original Message - From: Damian Conway [EMAIL PROTECTED] To: Perl6 [EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 9:35 PM Subject: Re: A6: overloading multis on constness of parameters Joe Gottman wrote: Will it be possible in perl6 to overload multis on the const

A6: overloading multis on constness of parameters

2003-03-11 Thread Joe Gottman
Will it be possible in perl6 to overload multis on the const-ness of a parameter, like C++ does? For instance, multi getX(Foo $self:) returns Int {...} #const version multi getX(Foo $self: is rw) returns Int is rw {...} #non-const version If getX were called on a const Foo object

Re: A6: overloading multis on constness of parameters

2003-03-11 Thread Damian Conway
Joe Gottman wrote: Will it be possible in perl6 to overload multis on the const-ness of a parameter, like C++ does? For instance, multi getX(Foo $self:) returns Int {...} #const version multi getX(Foo $self: is rw) returns Int is rw {...} #non-const version That second one would have to