At 10:02 AM -0800 1/24/03, Austin Hastings wrote:
There's also the fun of:--- Dan Sugalski <[EMAIL PROTECTED]> wrote:At 7:30 AM +0000 1/24/03, Piers Cawley wrote: >In my quest to eliminate as many explicit conditionals from my code as >possible, I found myself wondering if Perl 6's multidispatch mechanism >would allow one to write:Okay, I think I remembered the problem. Assume the following: list bar(int); # bar takes an int, returns a list scalar bar(int); # bar takes an int, returns a scalar and also assume the following: xyzzy(scalar); # xyzzy takes a scalar xyzzy(list); # xyzzy takes a list and then we make the call: xyzzy(bar(1)); Which bar do we call? And which xyzzy?In theory, if there's a return type expected, we could use that as the final arbiter. If not, but "if it looks like a scalar" ... xyzzy(bar 1); # Scalar xyzzy(bar(1)); # Scalar xyzzy(bar((1))); # List? xyzzy(bar(list(1))); #List xyzzy(bar(scalar(1))); # Scalar
Dog bar(int);
Cat bar(int);
and
xyzzy(Dog);
xyzzy(Cat);
with the call of:
xyzzy(bar(1));
Just one of the many brain-benders that I'm glad Larry has to deal with, not me. (Though this may be one of the reasons A6 is taking so long...)
--
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk