On Monday, February 10, 2003, at 05:56  PM, Luke Palmer wrote:
Indeed, this supports the distinction, which I will reiterate:

    - Arrays are variables.
    - Lists are values.
My hesitation about the 'arrays are variables' part is that Damian corrected me on a similar thing when I was writing about scalars. A variable is more like "a name of a container for a value", e.g. there's three parts to it:

- the name (what it's called in the namespace)
- the container (a specific container implementation)
- the value (what's inside it)

So I don't know that arrays are variables, so much as arrays are containers, if we want to get pedantic about it (which I don't, but... documentation... sigh).

Just to clarify... in P6, is this an array reference, or a list reference?

[1,2,3]

What about this?

\@array

I'd say both of them are array references, but there's no variable associated with the first one -- it's just an anonymous container. So I'd rewrite the definition to:

- Lists are an ordered collection of scalar values
- Arrays are containers that store lists

(Coupled with Uri's explanations, of course... it's the 'container' part that allows read/write, as opposed to simply read.) Yes/no?

Arrays are things that know about lists.  They know how to get a
particular element out of a list. They know how to *flatten
themselves, interpolating themselves into the surrounding list.  They
know how to map, grep, sort, splice themselves.  They know how to turn
themselves into a scalar.  Lists don't know how to do these things.
But is it OK for a list to be silently promoted to an array when used as an array? So that all of the following would work, and not just 50% of them?

(1..10).map {...}
[1..10].map {...}

(@a,@b,@c).pop
[@a,@b,@c].pop


MikeL

Reply via email to