zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] Documentation on (A) Create array parameter
@ 2017-02-22 11:40 Sebastian Gniazdowski
  2017-02-22 19:58 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Gniazdowski @ 2017-02-22 11:40 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1231 bytes --]

Hello,
(A) completion and documentation suggest straight creation:

       A      Create an array parameter with `${...=...}', `${...:=...}'
       or `${...::=...}'.  If this  flag  is
              repeated (as in `AA'), create an associative array
              parameter.  Assignment is made before sorting
              or padding; if field splitting is active, the word part is
              split before  assignment.   The  name
              part  may  be  a  subscripted  range  for ordinary arrays;
              the word part must be converted to an
              array, for example by using `${(AA)=name=...}' to activate
              field  splitting,  when  creating  an
              associative array.

This test:

% typeset -a overwrite_me=( 1 ); () { var_name="overwrite_me"; :
${(PA)var_name::=}; }; echo $overwrite_me"."${(t)overwrite_me}
.array

% () { local -a overwrite_me=( 1 ); () { var_name="overwrite_me"; :
${(PA)var_name::=}; }; echo $overwrite_me"."${(t)overwrite_me} }
.array-local

shows that parameter is reused if it exists, even if it exists on lower
scoping level. That's useful when coding, the patch adds one sentence
that clarifies this.

-- 
  Sebastian Gniazdowski
  psprint2@fastmail.com

[-- Attachment #2: A_create_array.diff --]
[-- Type: text/plain, Size: 615 bytes --]

diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index cf4f69e..386db08 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -964,6 +964,8 @@ assignment.  The var(name) part may be a subscripted range for
 ordinary arrays; the var(word) part em(must) be converted to
 an array, for example by using `tt(${(AA)=)var(name)tt(=)...tt(})'
 to activate field splitting, when creating an associative array.
+If the array parameter whose creation is requested already exists,
+it is reused, even when it exists at lower scoping level.
 )
 item(tt(a))(
 Sort in array index order; when combined with `tt(O)' sort in reverse

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-02-22 20:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-22 11:40 [PATCH] Documentation on (A) Create array parameter Sebastian Gniazdowski
2017-02-22 19:58 ` Bart Schaefer
2017-02-22 20:47   ` Sebastian Gniazdowski

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).