remember when calling a subroutine with & prepended, prototypes are never
looked at.

> -----Original Message-----
> From: Peter Scott [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, March 28, 2002 3:32 PM
> To: Dave Storrs; Perl 6 Beginners list
> Subject: Re: context of function calls
> 
> 
> 
> >Perl 6 Beginners list <[EMAIL PROTECTED]>
>       ^^^  ahem?
> 
> At 11:13 AM 3/28/02 -0800, Dave Storrs wrote:
> >Executive summary:  It looks like, no matter what context 
> foo() is called
> >in, its arguments are always evaluated in list context.  Is 
> this correct?
> 
> Unless a prototype overrides it, yes.  For instance, sprintf has an 
> implicit prototype that says it expects a scalar as its first 
> argument:
> 
> % perl -le 'sub foo{ print wantarray ? "list" : "scalar" }; 
> sprintf(foo)'
> scalar
> 
> >I had always understood that:
> >         - a function's arguments were evaluated in the same 
> context as the
> >context of the function (hmm...actually, thinking about it, 
> this seems
> >like it can't be right.  Is it simply always LIST, or can it vary?)
> 
> For builtins, look at the signature in perlfunc.  For your 
> own functions, 
> use a prototype to change it from LIST.  In general, you need 
> a good reason 
> to do this.
> --
> Peter Scott
> Pacific Systems Design Technologies
> http://www.perldebugged.com
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

----------------------------------------------------------------------------
--------------------
The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to