On 9/23/06, Audrey Tang <[EMAIL PROTECTED]> wrote:

在 Sep 23, 2006 8:36 PM 時,Markus Laire 寫到:

> On 9/23/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>>      @args = [EMAIL PROTECTED],1,2,3;
>> -    push [,] @args;    # same as push @foo,1,2,3
>> +    push [,] @args;    # same as push(@foo: 1,2,3)
>
> I don't quite understand this. Shouldn't C<[,] @args> be equivalent to
> C<[EMAIL PROTECTED],1,2,3> just as C<[+] 0,1,2,3> is equivalent to C<0+1+2+3>?
>
> So why is there C<:> instead of C<,> after C<@foo>?
>
> Does this have something to do with the fact that C<@args> is
> C<[EMAIL PROTECTED],1,2,3> and not C<@foo,1,2,3>?

Exactly. Per this interpretation, [EMAIL PROTECTED] is shorthand for \(@foo :), 
and

I think that this shorthand should be mentioned somewhere. From some
of the examples I thought that C<[EMAIL PROTECTED], @bar> would be equivalent to
C<\(@foo, @bar)>

[,] would first flatten the contents of @arg, and then process each one;
if an element is Capture, it is joined into the current arglist; if
it's not,
then it's made a simple positional.

I wasn't sure about this treatment, so I checked on #perl6 with Larry;
an alternative is to treat the elements of @foo always as positional
arguments, but that will make the two [,] calls below nonequivalent:

     my @args = [EMAIL PROTECTED], 1, 2, 3;
     [,] @args;
     [,] [EMAIL PROTECTED], 1, 2, 3;

I'd prefer to make them equivalent, on the principle that all listops
conceptually flatten+concat their arguments first, and then process
each element regardless of its origin.

Thanks,
Audrey




--
Markus Laire

Reply via email to