From: "Bart Schaefer" <schaefer@brasslantern.com>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: 3.1.5-pws-6 + assorted: Doc for local parameter scope
Date: Thu, 4 Feb 1999 22:23:53 -0800 [thread overview]
Message-ID: <990204222353.ZM20944@candle.brasslantern.com> (raw)
The doc currently says:
... `unset' can be used to delete a parameter while it is still in scope;
this will reveal the next outer parameter of the same name.
This is not the case and hasn't been for some while. Try:
zsh% function scope() { x=y; local x=z; unset x; echo $+x }
zsh% scope
0
There's also a bug in the caveats for special parameters; they don't merely
"remain special when unset." They can't be made local at all.
Happily, "tied" parameters created by "typeset -T" appear to deal properly
with scoping:
zsh% tied() { foo=(x y z); local foo; foo=ABC; echo $FOO ; FOO=1:2:3 }
zsh% typeset -T FOO foo ; tied ; echo $foo
x:y:z
1 2 3
Note that assigning to the local foo did not change the global FOO, but
that assigning to the global FOO _did_ change the global foo. This opens
up some very interesting possibilities for stupid zsh tricks.
Index: Doc/Zsh/params.yo
===================================================================
--- params.yo 1998/12/16 10:00:53 1.5
+++ params.yo 1999/02/05 06:11:56
@@ -40,7 +40,8 @@
(Parameters are dynamically scoped.) The tt(typeset) builtin, and its
alternative forms tt(declare), tt(integer), tt(local) and tt(readonly)
(but not tt(export)), can be used to declare a parameter as being local
-to the innermost scope.
+to the innermost scope. Note that em(special) parameters cannot be made
+local.
When a parameter is read or assigned to, the
innermost existing parameter of that name is used. (That is, the
@@ -49,9 +50,8 @@
causes it to be created in the em(outer)most scope.
Local parameters disappear when their scope ends.
-tt(unset) can be used to delete a parameter while it is still in scope; this
-will reveal the next outer parameter of the same name. However, em(special)
-parameters are still special when unset.
+tt(unset) can be used to delete a parameter while it is still in scope;
+any outer parameter of the same name remains hidden.
texinode(Array Parameters)(Positional Parameters)(Local Parameters)(Parameters)
sect(Array Parameters)
The value of an array parameter may be assigned by writing:
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
reply other threads:[~1999-02-05 6:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=990204222353.ZM20944@candle.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).