--- 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?" > > If someone can come up with a simple but accurate definition, it > would be helpful.
How's this? ============ A number is a literal (e.g., 3) that can be used as the initializer for a scalar. A string is a literal (e.g., "Hello, world") that can be used as the initializer for a scalar. A list is a literal (e.g., '(3, "Hello, world")') that can be used as the initializer for an array. With one exception, places in perl that require "a scalar" can be given a literal number or string. Likewise, 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 - a list can be indexed, examined, copied, iterated over using for, etc. But in order to make changes you have to have an array -- a container for a list. Because arrays can do all the things above, plus shift, pop, append, delete, etc. ==========? =Austin