From: "René 'Necoro' Neumann" <lists@necoro.eu>
To: zsh-users@zsh.org
Subject: Re: Local inner functions
Date: Thu, 24 Mar 2011 09:50:41 +0100 [thread overview]
Message-ID: <4D8B05E1.9010605@necoro.eu> (raw)
In-Reply-To: <c5d4f6a1f045fbb991229a7d8601e17e.squirrel@gameframe.net>
[-- Attachment #1: Type: text/plain, Size: 1113 bytes --]
Am 24.03.2011 02:16, schrieb nix@myproxylists.com:
>> Hi all,
>>
>> I often use the construct of defining a function inside another
>> function. Now I discovered, that these pour into the environment, i.e.
>> if I have
>>
>> foo ()
>> {
>> bar () { }
>> }
>>
>> and I execute "foo", "bar" is now visible in my environment.
>>
>> Is there some way of making 'bar' to be local to 'foo'? Using the
>> 'local' keyword does not work :).
>>
>> I know, that in principle it is possible to explicitly 'unfunction'
>> functions, but this is not a usable way sometimes.
>>
>> Thanks for your help,
>> René
>>
>>
>
> I think localing is possibly only to variables as you know. What you're
> trying to achieve by localing 'bar' inside 'foo'?
>
Avoiding name space cluttering and also avoiding the possibility of
overwriting already existing functions or aliases.
Take for example:
bar () {
echo muh
}
...
foo () {
bar () { echo moep }
}
No after executing 'foo', 'bar' does something completely different,
which is in most cases extremely unwelcome.
- René
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
next prev parent reply other threads:[~2011-03-24 8:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-23 23:23 René 'Necoro' Neumann
2011-03-24 1:16 ` nix
2011-03-24 8:50 ` René 'Necoro' Neumann [this message]
2011-03-24 1:41 ` Bart Schaefer
2011-03-24 9:38 ` René 'Necoro' Neumann
2011-03-24 11:51 ` Mikael Magnusson
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=4D8B05E1.9010605@necoro.eu \
--to=lists@necoro.eu \
--cc=zsh-users@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).