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

Re: PATCH: [key]=value syntax, work in progress

On Tue, Sep 12, 2017 at 1:25 PM, Peter Stephenson
<p.w.stephenson@xxxxxxxxxxxx> wrote:
> (I take silence to mean "grmf why are you even bothering to do this
> frmkfplp", with consontantal clusters different by local factors.)

Or just lack of time ...

>  If the parameter var(name) exists and is a scalar, it is replaced by a new
>  array.  To append to an array without changing the existing values, use
> -the syntax:
> +one of the following:
>  ifzman()
>  indent(var(name)tt(+=LPAR())var(value) ...tt(RPAR()))
> +indent(var(name)tt(+=LPAR())tt([)var(key)tt(]=)var(value) ...tt(RPAR()))

What does "append" mean when the keys are specified?  If I have

arr=( 1 2 3 4 5 )

and I do

arr+=( 6 [2]=7 8 )

does that even make sense?  That's certainly not "appending" to arr[2].

The other point that this raises is that in ksh "typeset -p" of an associative
array outputs e.g.

typeset -A x=([y]=2 [z]=1)

and that's the only way to assign an associative array; if you assign without
the [k]=v syntax the parameter converts into an ordinary array.  Is this going
to get enforced when KSH_ARRAYS and/or KSH_TYPESET are in effect?

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