Lightning flashed, thunder crashed and Dan Sugalski <[EMAIL PROTECTED]> whispered:
| > > Doesn't it make more sense to get rid of arrays and just use hashes?
| >
| >I guess it depends on what you think makes sense; but it seems to me
| >that an array is a more fundamental data type; that it's easier (i.e.
| >more efficient) to build associative arrays from arrays, than vice versa.
|
| It's silly to throw either of them out. Perl might be many things, but a
| reductionist language it ain't...
Why is it silly? Hashes and arrays are *conceptually* very similar (even
if they are extremely different implementation-wise). One of them has
implicit key, the other has an explicit key. They both provide some sort
of ordered collection (plural), even if it is difficult to understand what
the order is of hashes. Seems to me we could eliminate arrays and just
keep hashes. We could promote "=>" to be a key/value constructor while
elements that don't have the "=>" use a sequential number. Think of it
like this:
# Example "array"
%array = qw/foo bar blah blech/;
# Same thing, but explicit, a hash
%array = (0 => "foo", 1 => "bar, 2 => "blah", 3 => "blech");
# A combination using implicit values
%hash = (fn => "Bob", ln => "Smith", 10, 15, age => 35);
# Same thing, using explicit
%hash = (fn => "Bob", ln => "Smith", 0 => 10, 1 => 15, age => 35);
-spp