On 2003-02-07 at 12:18:21, Austin Hastings wrote:
> > Although this may reasonably be regarded as a special case; you
> > certainly can't pop a list:
> >
> > (1,2,3).pop => error
>
> But could you do it the other way (function instead of method)?
> pop (1,2,3) => ?
Nope. At least, not in Perl 5:
Type of arg 1 to pop must be array (not list)
> > But there's also the case of anonymous arrays, constructed through
> > reference via [ . . . ]. These are pop'able:
> >
> > [1,2,3].pop => 3
> >
> > But they certainly aren't lvalues:
> >
> > [$a,$b,$c] = 1,2,3 => error
>
> Actually, they're literal array references, not arrays.
You can't have an array reference without an array; the reference has
to refer to something. :) The referred-to-array in this case has no name,
hence "anonymous arrays, constructed through reference".
> I'm unsure how the mechanics are going to act in p6, since we're hiding
> the -> on refs. But in my heart of (c coding) hearts, it's a pointer.
A reference is fundamentally a pointer, but that doesn't help. My point
was that if you're talking about lists vs. arrays, you have at least
three different syntaxes to distinguish:
(1,2,3)
@arrayName
[1,2,3]
These all do different things, and autoconversion just adds to the
confusion - for instance, @arrayName is normally an array, but in
certain contexts it will be automatically turned into a reference
($aRef = @arrayName) or flattened into a list (print @arrayName).
--
Mark REED | CNN Internet Technology
1 CNN Center Rm SW0831G | [EMAIL PROTECTED]
Atlanta, GA 30348 USA | +1 404 827 4754