Luke Palmer <[EMAIL PROTECTED]> writes:

> On 7/26/05, Ingo Blechschmidt <[EMAIL PROTECTED]> wrote:
>> Hi,
>> 
>> are the following assumptions correct?
>> 
>>   sub foo ([EMAIL PROTECTED]) { @args[0] }
>> 
>>   say ~foo("a", "b", "c");     # "a"
>
> Yep.
>
>>   my @array = <a b c d>;
>>   say ~foo(@array);            # "a b c d" (or "a"?)
>>   say ~foo(@array, "z");       # "a b c d" (or "a"?)
>
> "a" for both of these.  The *@ area behaves just like Perl 5's calling
> conventions.  I could argue for never auto flattening arrays, but then
> there'd really be no difference between @ and $.
>
>>   say ~foo([EMAIL PROTECTED]);           # "a"
>>   say ~foo(*(@array, "z"));    # "a"
>
> Hmm, *(@array, "z")... what does that mean?  Whatever it means, you're
> correct in both of these.  In the latter, the @array is in a
> flattening context, so it gets, well, flattened.
>
>>   sub bar ([EMAIL PROTECTED]) { [EMAIL PROTECTED] }
>> 
>>   say bar(1,2,3);              # 3
>>   say bar(@array);             # 1 (or 4?)
>
> 4

Wha? And I mean that sincerely. That's cockeyed. Surely a [EMAIL PROTECTED] in 
the
signature simply says 'gather up the rest of the args and stick 'em in this
list'. In this case @array is a single argument, so @args should be equal to
[EMAIL PROTECTED] If I'm calling the function and I want @array to be treated as
anything but a single argument I use [EMAIL PROTECTED]

>>   say bar(@array, "z");        # 2 (or 5?)
>
> 5

Double wha? That's even worse.

Do you claim that 

   say bar('z', @array)

also emits 5? Ick.


>>   say bar([EMAIL PROTECTED]);            # 4
>
> Yep.

So how *do* I pass an unflattened array to a function with a slurpy parameter?

Reply via email to