zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Cc: Tomoki Sekiyama <tomoki.sekiyama@gmail.com>
Subject: Re: [PATCH] Enable further expansion of parameter name by ${!...}
Date: Mon, 26 Jan 2015 21:48:31 -0800	[thread overview]
Message-ID: <150126214831.ZM551@torch.brasslantern.com> (raw)
In-Reply-To: <CAM1upfMhyMPCn5urXPUjSTE2K2T3KyaZG6cg2v8vDhWwmHruvw@mail.gmail.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".)

}                     # ksh       bash     zsh(default)       zsh(KSH)
} echo ${!foo[bar]}   # foo[bar]  piyo     bad substitution   bar

I find this one interesting, because the ksh doc says it "expands to the
name of the subscript" which would seem to me to fit the zsh(KSH) column
more than the ksh column.

Ksh also has the special case ${!foo[bar..baz]} which treats the array
keys as an alphabetical list and generates a sub-list of them from "bar"
through "baz" (uninteresting in this example).

} According to this, introducing bash-like behaviors instead of "bad
} substitution" error will not hurt zsh even 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.


  parent reply	other threads:[~2015-01-27  5:48 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 [this message]
2015-01-28  3:21           ` Tomoki Sekiyama
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=150126214831.ZM551@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=tomoki.sekiyama@gmail.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).