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

Re: PATCH: mixed [key]=val and native syntax



Peter Stephenson wrote on Sun, 24 Sep 2017 17:26 +0100:
> +++ b/Doc/Zsh/params.yo
> @@ -109,10 +109,19 @@ of subscript expression that may be used when directly subscripting a
>  variable name, described in the section Array Subscripts below, are not
>  available.
>  
> -When assigning with this third form, every element must use this syntax or
> -an error is generated.  Likewise, if the first entry does not match this
> -form, any later entry that does is taken  as a simple value rather than a
> -key / value pair.  Both var(key) and var(value) undergo all forms of expansion
> +The syntaxes with and without the explicit key may be mixed.  Any absent
> +var(key) is deduced by incrementing the index from the previously
> +assigned element.  Note that it is not treated as an error
> +if latter assignements in this form overwrite earlier assignments.


"Any absent var(key)" sounds like it describes empty square brackets followed
by an equals sign.

-Any absent var(key) is...
-An implicit var(key) is...

> @@ -159,6 +168,10 @@ indent(tt(set -A) var(name) var(key) var(value) ...)
>  indent(var(name)tt(=LPAR())var(key) var(value) ...tt(RPAR()))
>  indent(var(name)tt(=LPAR())tt([)var(key)tt(]=)var(value) ...tt(RPAR()))
>  
> +Note that only one of the two syntaxes above may be used in any
> +given assignment; the forms may not be mixed.  This is unlike the case
> +of numerically indexed arrays.

For assocs would it make sense to allow mixing, but not between key and value, e.g., 

    typeset -A a=( k v [k2]=v2 k3 v3 )

but not

    typeset -A a=( k [k2]=v2 v )

?

>

P.S. An out-of-tree 'make' generates Doc/*.1 in the source tree, rather than in
the build tree.



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