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

Re: indirect array element assignment?



On Sat, Jul 2, 2022, at 11:41 PM, Bart Schaefer wrote:
> That does in fact mean that this works too, now that I think of it:
>
> ${(P)${:-${v}[2]}::=mango}

Even better!   Though gosh it does start to cry out for dedicated
assignment syntax/parsing.  I always though it was rather a pity that
some predecessor (ksh maybe?) claimed 'let' for arithmetic so it's
not free:   let ${v}[2] ?= (peach apricot)   etc  would be easier
to deal with.   But perhaps this was the thought-process that
unleashed csh on the world, so maybe not.

> For that to work, ${${X}} would have to mean the same as ${(P)X}.  As
> a general rule nested expansions are processed innermost-leftmost, and
> substitute rvalues rather than lvalues.

Yes.  It didn't seem *too* far off, but I traced it now with gdb
through paramsubst() and I follow what you mean.





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