From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14693 invoked by alias); 16 Nov 2016 19:14:46 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 39957 Received: (qmail 1833 invoked from network); 16 Nov 2016 19:14:46 -0000 X-Qmail-Scanner-Diagnostics: from mail-ua0-f169.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.217.169):SA:0(-0.0/5.0):. Processed in 1.076618 secs); 16 Nov 2016 19:14:46 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.217.169 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=Gx4lmVBxsGMDYy6tYWQwyucoAhztZbhmVuykpnHRYtU=; b=svqr1fRHah0fL2i9uygkpnnBGOqvvU0hPJV9EQb6GU+i11Rl5RniUC2i4Z3S1iN/dS nGheA/M1mc6ul+u3BsbgvJyyj7eB/9J25tZU8dqTfY0FJQ2+s1Djvco1J+BypJ+BCkWj rRYnw51ZiqJ6bIWVtRaF5zc5TMsszsnLwLrdoLBDCPwfyYgTy6oNtzJ5CIf6hxKicgY+ wCSEades8vxoP+XcOJQ9baEbzLR9yVdgkbiB5+GXP3CNXj5sg+B/geabwNm2Qui6gUlm dZWLW+RUOhkTOLBWXBqsyD3S4gbJAlmXXabFidbBYIt5u4YkAuP0c2CjJn7OCBLZu59B KTmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=Gx4lmVBxsGMDYy6tYWQwyucoAhztZbhmVuykpnHRYtU=; b=d29EMTcaBYEIfCdqhkRwdy5sXlUVzYGbDletIwj5Pg8wqk6unBOHSdTuO9zyUVoLck mM0h/AE4pwRYf26io7VbkekU1at4w97liuWrz/ySshM7sEb6mcy3rxQR8+Zp2w6GQC21 /I6LH0LTURy//j4m8fmT6ATO89EP7d+7swYFQ0BCzdfAmL3mpT3l/eGliy+QYuPc5yz3 pe61f0t0yfSprJNbhEtfXNItEb0zEr7PqW8jQbUOv+himiBTgw3oJWBQS4RNhfsmzTTy H2Y7vaPRFkSTgPuAD8By5mlscbZLbyuyxNypUiMvwa4XEAdLlADMaCeFUrmL9v67d+DK AqUw== X-Gm-Message-State: ABUngvc7I2usiqv1T3Jxygg0kRg3X8l7u8ulCYzWOl1r81+oGhccnr4BpiyExu79T7g69Q== X-Received: by 10.176.16.75 with SMTP id g11mr2101994uab.5.1479322202180; Wed, 16 Nov 2016 10:50:02 -0800 (PST) From: Bart Schaefer Message-Id: <161116105013.ZM32526@torch.brasslantern.com> Date: Wed, 16 Nov 2016 10:50:13 -0800 In-Reply-To: <77EB3614-F9E2-4BEB-B93C-99DFD34A504F@kba.biglobe.ne.jp> Comments: In reply to "Jun T." "Re: [PATCH] Optimization of getarrvalue()" (Nov 16, 11:06pm) References: <1478635899.1897979.781551353.05792438@webmail.messagingengine.com> <20161109114207.6b929440@pwslap01u.europe.root.pri> <161109080328.ZM6075@torch.brasslantern.com> <20161115195721.43648236@ntlworld.com> <77EB3614-F9E2-4BEB-B93C-99DFD34A504F@kba.biglobe.ne.jp> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: "zsh-workers@zsh.org" Subject: Re: [PATCH] Optimization of getarrvalue() MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Nov 16, 11:06pm, Jun T. wrote: } } The document says (15.2.1) } } If the KSH_ARRAYS option is not set, then by default accesses to an } array element with a subscript that evaluates to zero return an empty } string, } } so someone may expect that "${(@)a[0]}" is also replaced by an empty } string "" rather than removed from the command line. But I'm not sure. "Return an empty string" is not entirely accurate. For example: torch% setopt nounset torch% a=() torch% print $a[0] zsh: a[0]: parameter not set It would be more accurate to say "accesses to an array element with a subscript that evaluates to zero behave in the same way as accesses to any unset scalar parameter." } And I fear changing this behavior might break some existing scripts. The reason too-large subscripts behave differently than too-small is that arrays can be extended to the right but not to the left. That is, if you assign to ary[bignum] you implicitly create empty elements for any unoccupied indices less than bignum. (This differs from e.g. bash which uses a sparse implementation of arrays so the intervening elements remain unset.) A reference "off the right end" of the array behaves consistently with a reference into such a "gap". (This is also in part why I attempted to engage on NO_UNSET being too aggressive with arrays, but nobody took up the discussion.) Zero is special in that it's neither a "gap" nor an error (unless you try to assign to it).