On Fri, Jan 24, 2003 at 10:02:13AM -0800, Austin Hastings wrote:
> --- 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

Strange.  I think parameters to subroutines are in list context unless
stated otherwise.

-Scott
-- 
Jonathan Scott Duff
[EMAIL PROTECTED]

Reply via email to