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

Re: uninvited members of associative array



On Sun, Dec 18, 2022 at 12:12 PM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>
> [[[
> If tt(PLUS()A) is used and var(name) is an array, the
> given arguments will replace the initial elements of that array; if no
> var(name) is specified, all arrays are printed without their values.
> ]]]
>
> What does it get right?  What doesn't it get right?  What should be
> gotten right that isn't being gotten right?  How might that be phrased?

So, there are a couple of problems with it.
(1) It's not explicit about what "initial elements" are; that could
still refer to the entire array, or to the subset of current elements
with which the array was first initialized.
(2) It doesn't explain what effect this has on associative arrays,
which are unordered.

For (1) we need to state that, when there are N arguments to "set +A",
normal array positions 1 - N (or 0 - N-1 for ksharrays) are replaced,
and arguments N+1 (ibid.) are unchanged.

For (2) the entire associative array is replaced for +A just as it is
for -A.   I suppose that could be altered so that it works like
aa+=(...) which might be useful.




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