zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: zsh-workers@sunsite.dk
Subject: Re: [frederik@ugcs.caltech.edu: Bug#236748: zsh: associative array documentation reference broken]
Date: Tue, 09 Mar 2004 10:57:56 +0100	[thread overview]
Message-ID: <26321.1078826276@trentino.logica.co.uk> (raw)
In-Reply-To: <1040308221959.ZM13999@candle.brasslantern.com>

Bart wrote:
> On Mar 8, 10:23am, Clint Adams wrote:
> }
> }  For associative arrays, `[*]' or `[@]' evaluate to all the values
> }  (not the keys, but see Subscript Flags below), in no particular
> }  order.
> } 
> } There is nothing relevant to this syntax under Subscript Flags.
> 
> Yes, there is.  The k, K, and e subscript flags all affect the
> intepretation of * and @.  It's true that [(K)*] is nearly the same
> as [*], but [(k)*] is quite different, as both [(k)@] and [(K)@] are
> from [@].

Yes, I mentioned this in the original thread
(http://bugs.debian.org/236748), though I didn't check which flags
apply.

> }  For associative arrays, `[*]' or `[@]' evaluate to all the values
> }  (not the keys, but see the documentation for the 'k' flag under
> }  Parameter Expansion Flags in zshexpn(1)), in no particular order.
> 
> No, this is NOT what it should say, or at least not ALL that it should
> say.

I think the change as currently proposed is an improvement because it
is far easier to remember (k) and (v) as the way to control whether
keys or values are output. So the emphasis should be on the expansion
flag but it might be useful to mention the subscript flags too.

I've been meaning to make (k) and (kv) work for normal arrays too. The
subscript flags do too many different things which makes them
complicated to remember. Whether things can be changed in a backward
compatible way, I don't know but in any case changes would probably 
need the long overdue parameter code rewrite. I'll bore you with my
thoughts anyway.

The only unique feature the subscript flags offer is the ability to do
reverse subscripting (i.e. looking things up by value instead of key)
and to use pattern matching instead of exact string matches. Those two
features require just two flags (and even the latter is very similar to
${var:#pat}).

We have (k) and (v) flags to control what is returned and if an array
of results is returned, subsequent array indexing such as [1] and [-1]
would replace the abilities of (i) and (I) to return just highest and
lowest values. That'd be easier to read and easier to remember at the
expense of being more to type.

Oliver


      reply	other threads:[~2004-03-09  9:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-08 15:23 Clint Adams
2004-03-08 15:51 ` Peter Stephenson
2004-03-08 16:35   ` Clint Adams
2004-03-08 16:40     ` Peter Stephenson
2004-03-08 17:02       ` Clint Adams
2004-03-08 22:19 ` Bart Schaefer
2004-03-09  9:57   ` Oliver Kiddle [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=26321.1078826276@trentino.logica.co.uk \
    --to=okiddle@yahoo.co.uk \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).