From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26803 invoked by alias); 4 Nov 2015 14:48:52 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20894 Received: (qmail 27697 invoked from network); 4 Nov 2015 14:48:50 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Authority-Analysis: v=2.1 cv=T/C1EZ6Q c=1 sm=1 tr=0 a=NKvc7L9z7/b0bXwZ1ZmuGA==:117 a=NKvc7L9z7/b0bXwZ1ZmuGA==:17 a=N659UExz7-8A:10 a=IyKeLqVbQTJCVcSrjh8A:9 a=pILNOxqGKmIA:10 Message-id: <563A1ACF.4020902@eastlink.ca> Date: Wed, 04 Nov 2015 06:48:47 -0800 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-version: 1.0 To: zsh-users@zsh.org Subject: Re: easy calling of associative array? References: <56369C7B.2030604@eastlink.ca> <1237641446422150@web6m.yandex.ru> <5636B333.8060300@eastlink.ca> <151101190842.ZM16752@torch.brasslantern.com> <5636D99F.2030807@eastlink.ca> <151101225100.ZM16882@torch.brasslantern.com> <563784B5.3040901@eastlink.ca> <151102082808.ZM17640@torch.brasslantern.com> <5637AC27.8010007@eastlink.ca> <151102130518.ZM17830@torch.brasslantern.com> <5637EB66.9050301@eastlink.ca> <151103075730.ZM18820@torch.brasslantern.com> In-reply-to: <151103075730.ZM18820@torch.brasslantern.com> Content-type: text/plain; charset=windows-1252; format=flowed Content-transfer-encoding: 7bit On 11/03/2015 07:57 AM, Bart Schaefer wrote: > Using "typeset -gA ary" in "middle" prevents this; it says "don't declare > a new local parameter, use the one that is already in scope." > > The usage with "-g ary[idx]" says "don't attempt to index into a new local > parameter $ary, instead index into the existing $ary if there is one." > Which is what you want if the name "ary" has been passed down through $1. > Ok, that's quite clear. Thanks Bart. Historian that I am, I expect that if the writers of the first shells realized how far their work would evolve, they'd have introduced rigorous C-ish scoping and typing at the getgo, since largeish projects sure could use it. One is often unsure what is going on with variables when there are several levels of functions. This use of typeset sounds like excellent insurance.