zsh-workers
 help / color / mirror / code / Atom feed
From: Tomoki Sekiyama <tomoki.sekiyama@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: [PATCH] Enable further expansion of parameter name by ${!...}
Date: Tue, 27 Jan 2015 22:21:42 -0500	[thread overview]
Message-ID: <CAM1upfPpLjhgGvAt+QR3OBQm0_hqcRB5e0Z8i7qmWJZmCdOxJw@mail.gmail.com> (raw)
In-Reply-To: <150126214831.ZM551@torch.brasslantern.com>

2015-01-27 0:48 GMT-05:00 Bart Schaefer <schaefer@brasslantern.com>:
> On Jan 26,  3:00pm, Tomoki Sekiyama wrote:
> }
> }                     # ksh       bash     zsh(default)       zsh(KSH)
> } echo $aaa           # bbb       bbb      bbb                bbb
> } echo ${!aaa}        # aaa       ccc      bad substitution   bbb
>
> OK, but the point is that ideally in that last row the zsh(KSH) case
> would be "aaa".  I guess this is no worse than the difference of
> ${array[1]} with or without ksharrays set.  (If "nameref aaa=bbb",
> then the first column of the last row would be "bbb".)

I agree. So until nameref is introduced, ${!aaa} should always be "aaa" in
ksh emulation mode.

> My question is, why choose the bash behavior for the zsh default and
> not the ksh behavior?  If we make the bash behavior the default, then
> also adding namerefs as a default leaves us deviating from ksh on the
> meaning of ${!aaa} for identifiers that are not namerefs.

I'm not familiar with zsh policy to determine default behaviors, but if
there is future plan (or possibility) to introduce nameref, we certainly
should provide this bash-like indication under an option.
For example:

  $ unsetopt banghist
  $ typeset -A foo
  $ foo[bar]=qux
  $ foo[baz]=piyo
  $ baz=BAZ
  $ echo ${foo[@]}
  qux piyo
  $ echo ${!foo[@]}
  bar baz
  $ setopt bashindirection
  $ echo ${!foo[bar]}
  BAZ
  $ emulate -R ksh
  $ echo ${!foo[bar]}
  foo[bar]

Without these options, we might only support '!' for ${!foo[@]}
getting arrays of the keys of foo.
How do you think of this?


  reply	other threads:[~2015-01-28  3:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-25  9:15 Tomoki Sekiyama
2015-01-25 18:14 ` Peter Stephenson
2015-01-25 18:23   ` Mikael Magnusson
2015-01-25 20:24 ` Bart Schaefer
2015-01-25 20:38   ` ZyX
2015-01-25 21:39     ` Bart Schaefer
2015-01-26 20:00       ` Tomoki Sekiyama
2015-01-26 20:44         ` ZyX
2015-01-27  5:48         ` Bart Schaefer
2015-01-28  3:21           ` Tomoki Sekiyama [this message]
2015-01-28 18:41             ` Bart Schaefer
2016-11-11 16:58           ` Bart Schaefer

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=CAM1upfPpLjhgGvAt+QR3OBQm0_hqcRB5e0Z8i7qmWJZmCdOxJw@mail.gmail.com \
    --to=tomoki.sekiyama@gmail.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /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).