[EMAIL PROTECTED] writes:
: Given:
: 
:    > $a = 1;
:    > @b = (1, 2, 3);
: 
: Damian suggested that:
: 
:    > $a = $a ^+ @b 
:    > 
:    > becomes:
:    > 
:    > $a = ($a, $a, $a) ^+ (1, 2, 3)
:    > $a = (1, 1, 1) ^+ (1, 2, 3)
:    > $a = (2, 3, 4)
:    > $a = 4;
: 
: Whereas Piers thought that:
: 
:    > $a = $a ^+ @b 
:    > 
:    > becomes:
:    > 
:    > $a = [$a, $a, $a] ^+ [1, 2, 3]
:    > $a = [1, 1, 1] ^+ [1, 2, 3]
:    > $a = [2, 3, 4]
: 
: 
: On this matter I can categorically state...that it is either the former,
: or the latter, or something else entirely.
: 
: ;-)

You're right.  :-)

Actually, I believe Piers is righter.  The comma operator is no longer
the C comma operator in Perl 6; it always builds a list object.  If you
happen to want only the last one, subscript with [-1].  But most of
the time, the C comma operator is used in void context.

:    > Or am I mistaken about the new perl6 syntax for 
:    > 
:    > $a = @b;
: 
: No. That *is* the same as C<$a = \@b>.

More generally, \ and [] are really only required in list context, or
to make an explicit reference to a scalar.  Any list in scalar context
becomes a list object.  (Which, if evaluated in a numeric context,
returns the length.)

A list in list context also returns a list object.  The list context
merely promises that the list will be treated as flattened.  It doesn't
necessarily flatten it immediately as Perl 5 does.

:    > Or does the hyper operator 'listify' the stuff it's working on?
: 
: That is indeed the question. Whether hyperoperators hyperoperate on
: lists or on arrays, and which of those they build if build they must.

Hyperoperators hyperoperate on objects.  Some objects are scalars, and
some objects are of higher dimensionality.  The ^ is essentially
a DWIM marker on the operator, which would otherwise assume both objects
to be scalar.

Larry

Reply via email to