On Wed, Jan 29, 2003 at 09:44:27AM -0500, Aaron Sherman wrote: > > Yes, I would expect that. In my opinion there is no difference between > an array and a hash other than the underlying storage and the > type-management of the key. I'm increasingly of the opinion that a) > there should be no @ vs %, there should be no {} vs [], there should be > a keys, values, defined, delete, exists, push, pop, shift, unshift for > every container and foreach shouldn't give a damn.
I think that arrays and associative tables are very different entities for two reasons: -type of keys. array keys are integers -cost of insertion and deletion operations: O(n) and lower for associative table ( O(1) if you don't care for key ordering, O(log(n)) if you care for ordering). This is enough to warrant different syntaxes for arrays and hash. This is one of the main things that attracted me to Perl, variable names ($a, @a, %a) were a clear indication of behavior. Perl6 should also support associative tables with ordered keys. The default type of associative tables should be hashes. # hash based associative table metonymically called hash my %assoctbl1; # tree based associative tables. properties should specify the tree algo used and possibly the ordering function. my %assoctbl2 is redblack; my %assoctbl3 is ordered( &sortfun); > > But, that would be a different language, and Perl has hashes and arrays. > So, the most we can do is make them not work too differently. > -- stef