--- "Mark J. Reed" <[EMAIL PROTECTED]> wrote:
> On 2003-02-07 at 11:13:07, Austin Hastings wrote:
> > --- Michael Lazzaro <[EMAIL PROTECTED]> wrote:
> > > I'm trying, and failing, to accurately and definitively answer
> the 
> > > question "what's the difference between an array and a list in
> > > Perl6?"
> > 
> > How's this?
> > ============
> > 
> > A list is a literal (e.g., '(3, "Hello, world")') that can be used
> as
> > the initializer for an array.
> > 
> > [...] places in perl that require "an array" can be given a list.
> The
> > exception is lvalues -- you can't say 3 = "Hello, world"; -- the
> > left-hand side of an assignment operation requires an assignable
> > thing, not a literal.  So the difference between a list and an
> array
> > is one of assignability.
> Not really, though.  A list can be an lvalue, provided it is a list
> of lvalues:
> 
>         ($a, $b, $c) = 1,2,3;

Hmm. You're kind of weaseling there because that's "DWIM magic" for 3
lines of code, but I don't know how to get there.

> 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) => ?

> 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.

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.

=Austin

Reply via email to