Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: assoc array memory mucking, and semantics of patterned keys



"Bart Schaefer" wrote:
> The final possibility is to change the meanings of (r) and (i) when an
> AA is involved, so that (r) means search the values and (i) means search
> the keys.

Without thinking too hard, because I want to get some work done today,
I think I prefer this, because the (k) and (v) flags always refer to
what's returned, while the (r) and (i) flags always refer to what's
being searched.  It's both neat and powerful.  It's maybe annoying
it's different from normal arrays, but I think understandably so.
Once you've got the point that (i) tells you to search the index, not
return it, it's entirely logical.  Otherwise the meanings of (k) and
(i) are mixed in a slightly messy way.  It just needs one sentence in
the manual saying
   
   i [what happens with ordinary arrays]
  
     With associative arrays, specifies that the keys of the array
     should be searched for a match.  The part of the array returned
     is controlled by the (k) and (v) substitution flags in this case.

and pretty much everything else is covered already.

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56100 Pisa, Italy



Messages sorted by: Reverse Date, Date, Thread, Author