> Date: Tue, 11 Feb 2003 10:34:57 -0800
> From: Michael Lazzaro <[EMAIL PROTECTED]>
>
> 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).
Well, that doesn't assume the definition of the variable includes a
namespace entry. So, yes, I suppose container would be better. The
thing the namespace entry points to, but not the value.
> 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
I'd agree.
> -- 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
I think that's a pretty good one.
> (Coupled with Uri's explanations, of course... it's the 'container'
> part that allows read/write, as opposed to simply read.) Yes/no?
Yes, from my perspective, the container is the one that knows
read/write. Basically, the only you can't modify lists is that they
have no operations defined that can modify them. Arrays on the other
hand, do.
>
> > 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 {...}
I don't really know here. I'm not sure whether this should work....
I think if lists don't have the C<map> method, that shouldn't work.
> (@a,@b,@c).pop
> [@a,@b,@c].pop
Why would you suppose the former to work? Or do you mean that to mean
(@a.pop,@b.pop,@c.pop)? Can lists have methods?
This clear distinction that I once had in my mind is getting blurrier
and blurrier. :(
Luke