zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: "Jun T." <takimoto-j@kba.biglobe.ne.jp>
Cc: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: [PATCH] Optimization of getarrvalue()
Date: Wed, 23 Nov 2016 16:55:13 -0800	[thread overview]
Message-ID: <CAH+w=7YN-pzoGn5AC260sS3yLMKRL0kjaSY1zMihRKs5wEiM1Q@mail.gmail.com> (raw)
In-Reply-To: <F678A4CE-CDBD-4BCE-BB43-DB55FFA82073@kba.biglobe.ne.jp>

On Mon, Nov 21, 2016 at 4:30 AM, Jun T. <takimoto-j@kba.biglobe.ne.jp> wrote:
>
> Maybe, but I still don't understand, for example, the following:
>
> % a=()
> % nargs "${(@)a[0]}"
> 1
> % a=( foo )
> % nargs "${(@)a[0]}"
> 0

OK, I agree that one is strange.  However:

> % a=( foo bar )
> % nargs "${(@)a[3]}"
> 1
> % nargs "${(@)a[3,3]}"     # or "${(@)a[3,4]}"  "${(@)a[3,5]}" ...
> 0

Two subscripts separated by a comma mean something different than one
subscript.  a[3] is a scalar, so adding (@) doesn't matter; a scalar
in double quotes is the empty string.  a[3,3] is an array, and an
array with the (@) flag in double quotes resolves to nothing if the
array is empty.  The only magic here is the already-magic semantics of
double-quoting "${a[@]}".

> More generally, $a[i,j] with i=$#a+1 is treated specially.

??  It's not treated any differently than i=$#a+N for any N >=0, is it?


  reply	other threads:[~2016-11-24  1:02 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20161108201233epcas1p1e2900e2d67af8b8558ebdb70eb7ad480@epcas1p1.samsung.com>
2016-11-08 20:11 ` Sebastian Gniazdowski
2016-11-08 21:58   ` Bart Schaefer
2016-11-09  7:11   ` Bart Schaefer
2016-11-09 11:42   ` Peter Stephenson
2016-11-09 16:03     ` Bart Schaefer
2016-11-14 12:32       ` Jun T.
2016-11-14 13:15         ` Jun T.
2016-11-14 13:57         ` Peter Stephenson
2016-11-14 15:35           ` Jun T.
2016-11-14 17:10           ` Bart Schaefer
2016-11-16  7:55             ` Sebastian Gniazdowski
2016-11-15 12:28         ` Peter Stephenson
2016-11-15 19:57         ` Peter Stephenson
2016-11-15 21:11           ` Bart Schaefer
2016-11-16 14:06           ` Jun T.
2016-11-16 16:14             ` Jun T.
2016-11-16 18:50             ` Bart Schaefer
2016-11-21 12:30               ` Jun T.
2016-11-24  0:55                 ` Bart Schaefer [this message]
2016-11-24 11:49                   ` Jun T.
2016-11-29  6:11                     ` Array slices that don't exist [was Optimization of getarrvalue()] Bart Schaefer
2016-11-29  9:34                       ` Peter Stephenson

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='CAH+w=7YN-pzoGn5AC260sS3yLMKRL0kjaSY1zMihRKs5wEiM1Q@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=takimoto-j@kba.biglobe.ne.jp \
    --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).