From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Obtaining the names of all local variables
Date: Thu, 25 Jun 2015 08:46:18 -0700 [thread overview]
Message-ID: <150625084618.ZM20163@torch.brasslantern.com> (raw)
Oliver mentioned:
> I did something like the following in _git recently. It works
> arr=( one two three )
> local $arr
This got me thinking, wouldn't it be helpful if zsh/parameter had an array
$locals that holds the names of all the local parameters? Then you could
needs_private_scope() { local -h $locals; ... }
It then occurred to me that it might be more natural to have "local" handle
this. But:
torch% () { local +m \* }
(anon): bad option: -m
Of course there's an ambiguity in both cases; given
typeset bar
scope1 () {
local foo
}
scope2 () {
local foo bar
scope1
}
Should "bar" be considered local in scope1 when called from scope2? If not,
this whole idea is somewhat moot; you'd need a way to select which scope
you want to know all the locals in, which is ugly to contemplate.
next reply other threads:[~2015-06-25 15:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-25 15:46 Bart Schaefer [this message]
2015-06-27 21:45 ` Oliver Kiddle
2015-06-27 23:08 ` Bart Schaefer
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=150625084618.ZM20163@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/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).