>It doesn't help that Camel II's glossary defines "array" as "A named list 
>of values, each of which has a unique key to identify it.  In a normal 
>array, the key is numeric... In a hash...the key is a string." and seems to 
>go to a lot of effort to deprecate "array" in favor of "list" (array 
>context: "A quaint, archaic expression used by people who have read the 
>first edition of this book.  Nowadays called 'list context'.").

Here's from Camel III.  I hope you find this more helpful than before.

    =item B<array>

    An ordered sequence of values, stored such that you can easily access
    any of the values using an integer subscript that specifies the value's
    offset in the sequence.

    =item B<array context>

    An archaic expression for what is more correctly referred to as I<list
    context>

    =item B<hash>

    An unordered association of I<key>/I<value> pairs, stored such
    that you can easily use a string I<key> to look up its associated
    data <value>.  This glossary is like a hash, where the word to be
    defined is the key, and the definition is the value.  A hash is
    also sometimes septisyllabically called an "associative array",
    which is a pretty good reason for simply calling it a "hash" instead.

    =item B<hash table>

    A data structure used internally by Perl for implementing associative
    arrays (hashes) efficiently.  See also I<bucket>.

    =item B<LIST>

    A syntactic construct representing a comma-separated list of
    expressions, evaluated to produce a I<list value>.  Each I<expression>
    in a R<LIST> is evaluated in a I<list context> and interpolated into
    the list value.

    =item B<list>

    An ordered set of scalar values,

    =item B<list context>

    The situation in which an I<expression> is expected by its surroundings
    (the code calling it) to return a list of values rather than a
    single value.  Functions that want a R<LIST> of arguments tell those
    arguments that they should produce a list value.  See also I<context>.

>Reading that, what would you say the difference between an array, a list, 
>and a hash is?

I'm not sure from reading that.  The answer that comes to my mind
is that an array has an AV (updatable array metadata header
structure) and a hash an HV (similarly), but a list--well, that's
just SVs sitting around on a stack somewher.  But that's not very
useful for anyone who's still confused.

>(My answer:  From that glossary, I'd say that 'array' and 'list' are 
>virtually synonymous.  From actual use, I'd say that an array can be an 
>lvalue, but a list is strictly an rvalue.)

Actually, you *can* use a list lvalueably, provided that each of that
list's components is also a legal lvalue.  For example:

    ($a, $b, $c, $d, @etc) = fn();

However, currently you can't switch those, even for lvaluable functions.

--tom

Reply via email to