zsh-workers
 help / color / mirror / code / Atom feed
4342a92aa96ad13ddb8c9c9de2ef85b7f31e7ad2 blob 3104 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
 
COMMENT(!MOD!zsh/param/static
Builtins for managing static-scoped parameters in function context.
!MOD!)
The tt(zsh/param/static) module is used to create parameters whose scope
is limited to the current function body, and em(not) to other functions
called by the current function.

This module provides a single autoloaded builtin:
ifnzman()
startitem()
findex(static)
cindex(static parameter, creating)
item(tt(static) [ {tt(PLUS())|tt(-)}tt(AHUahlprtux) ] \
[ {tt(PLUS())|tt(-)}tt(EFLRZi) [ var(n) ] ] [ var(name)[tt(=)var(value)] ... ])(
The tt(static) builtin accepts all the same options and arguments as tt(local)
(ifzman(zmanref(zshbuiltins))ifnzman(noderef(Shell Builtin Commands))) except
for the `tt(-)tt(T)' option.  Tied parameters may not be made static.

Although var(name)tt(=)var(value) sytax may be used in the argument list
to initialize scalar parameters, there is no corresponding reserved word
for tt(static), so the more general assignment syntax may not be used to
initialize arrays.  This may change in a future release.

If used at the top level (outside a function scope), tt(static) creates a
normal parameter in the same manner as tt(declare) or tt(typeset).  A
warning about this is printed if tt(WARN_CREATE_GLOBAL) is set
(ifzman(zmanref(zshoptions))ifnzman(noderef(Options))).  Used inside a
function scope, tt(static) creates a local parameter similar to one
declared with tt(local), except having special properties noted below.

Special parameters which expose or manipulate internal shell state, such
as tt(ARGC), tt(argv), tt(COLUMNS), tt(LINES), tt(UID), tt(EUID), tt(IFS),
tt(PROMPT), tt(RANDOM), tt(SECONDS), etc., cannot be made static unless
the `tt(-)tt(h)' option is used to hide the special meaning of the
parameter.  This may change in the future.
)
enditem()

Parameters declared with tt(static) have the following properties:
ifnzman()
startitemize()
itemiz(Within the function body where it is declared, the parameter
behaves as a local, except as noted above for tied or special parameters.)
itemiz(The type of a parameter declared static cannot be changed in the
scope where it was declared, even if the parameter is unset.  Thus an
array cannot be assigned to a static scalar, etc.)
itemiz(Within any other function called by the declaring function, the
static parameter does em(NOT) hide other parameters of the same name, so
for example a global parameter of the same name is visible and may be
assigned or unset.  This includes calls to anonymous functions, although
that may also change in the future.)
itemiz(An exported static remains in the environment of inner scopes but
appears unset for the current shell in those scopes.)
enditemize()

Note that this differs from the static scope defined by compiled languages
derived from C, in that the a new call to the same function creates a new
scope, i.e., the parameter is still associated with the call stack rather
than with the function definition.  It differs from ksh `tt(typeset -S)'
because the syntax used to define the function has no bearing on whether
the parameter scope is respected.
debug log:

solving 4342a92 ...
found 4342a92 in https://inbox.vuxu.org/zsh-workers/150924192305.ZM2680@torch.brasslantern.com/

applying [1/1] https://inbox.vuxu.org/zsh-workers/150924192305.ZM2680@torch.brasslantern.com/
diff --git a/Doc/Zsh/mod_static.yo b/Doc/Zsh/mod_static.yo
new file mode 100644
index 0000000..4342a92

Checking patch Doc/Zsh/mod_static.yo...
Applied patch Doc/Zsh/mod_static.yo cleanly.

index at:
100644 4342a92aa96ad13ddb8c9c9de2ef85b7f31e7ad2	Doc/Zsh/mod_static.yo

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).