zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@sunsite.dk
Subject: Re: ${(kv)foo[bar]}
Date: Sun, 03 Apr 2005 19:58:51 +0000	[thread overview]
Message-ID: <1050403195852.ZM4281@candle.brasslantern.com> (raw)
In-Reply-To: <200504032200.41605.arvidjaar@newmail.ru>

On Apr 3, 10:00pm, Andrey Borzenkov wrote:
} Subject: Re: ${(kv)foo[bar]}
}
} Although it is rather hard to understand why ${(kv)opt_args[(i)--media]} 
} should work and ${(kv)opt_args[--media]} not.

The rationalization is that with [(i)...] the subscript is a pattern, so
you may not know in advance what it's going to match, and therefore it
is useful to be able to return both the key and the value.  [(i)--media]
is a degenerate case where the pattern is a plain string.  Without the
(i), the subscript is always a plain string and therefore known, and you
don't need to be able to expand it.

The real reason, as I said, is that the implementation of subscripting
with [(i)...] does a scan of the hash keys rather than a simple hash
lookup; it's got code that's shared with (R) and (I) and therefore is
designed to return an array.  Implementing subscripting with a full
scan in the ordinary case just for (kv) would foil the reason for using
a hash table to begin with.


      reply	other threads:[~2005-04-03 19:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-03 10:35 ${(kv)foo[bar]} Andrey Borzenkov
2005-04-03 17:49 ` ${(kv)foo[bar]} Bart Schaefer
2005-04-03 18:00   ` ${(kv)foo[bar]} Andrey Borzenkov
2005-04-03 19:58     ` Bart Schaefer [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=1050403195852.ZM4281@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --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).