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; Although this may reasonably be regarded as a special case; you certainly can't pop a list: (1,2,3).pop => error 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 Unless some magic autoconversion happens. -- Mark REED | CNN Internet Technology 1 CNN Center Rm SW0831G | [EMAIL PROTECTED] Atlanta, GA 30348 USA | +1 404 827 4754