Michael Lazzaro wrote:

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


They're definately variables.  The container is a PerlArray,
which is a distinctly different object compared to a
PerlUndef.

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

[1,2,3]


I'd say it is an array reference.


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


There should be a variable attached, but just no name
attached to the variable.


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?


Maybe :-)


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


But this would mean that an implicit anonymous array would need
to be created, which isn't always possible in the middle of a
statement.  So, that would mean the compiler would need to be
smart enough to figure out when this will happen, and then
create the anonymous array beforehand, and then somehow
alias the list contents to the array.  Thats a heck of a lot
of magic going on there.


So that all of the following would work, and not just 50% of them?

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

I think this should be an error.  What object is the method
getting called on?

Is forcing the functional syntax on lists really that horrible?

   [1..10].map {...


I think this *should* work, although I'm not sure *how*.


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


This doesn't make any sense, since pop modifies the pop-ee.
What do you expect should happen here?



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

Same as above.


Joseph F. Ryan
[EMAIL PROTECTED]


Reply via email to