Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: easy calling of associative array?



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.



Messages sorted by: Reverse Date, Date, Thread, Author