From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29271 invoked by alias); 24 Mar 2011 08:51:02 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 15886 Received: (qmail 19555 invoked from network); 24 Mar 2011 08:50:50 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at necoro.eu does not designate permitted sender hosts) Message-ID: <4D8B05E1.9010605@necoro.eu> Date: Thu, 24 Mar 2011 09:50:41 +0100 From: =?UTF-8?B?UmVuw6kgJ05lY29ybycgTmV1bWFubg==?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110323 Lightning/1.0b3pre Thunderbird/3.1.9 MIME-Version: 1.0 To: zsh-users@zsh.org Subject: Re: Local inner functions References: <4D8A810A.3050300@necoro.eu> In-Reply-To: X-Enigmail-Version: 1.1.2 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigF45F6BC5412A4CAA62E56A46" --------------enigF45F6BC5412A4CAA62E56A46 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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=C3=83=C2=A9 >> >> >=20 > I think localing is possibly only to variables as you know. What you're= > trying to achieve by localing 'bar' inside 'foo'? >=20 Avoiding name space cluttering and also avoiding the possibility of overwriting already existing functions or aliases. Take for example: bar () { echo muh } =2E.. foo () { bar () { echo moep } } No after executing 'foo', 'bar' does something completely different, which is in most cases extremely unwelcome. - Ren=C3=A9 --------------enigF45F6BC5412A4CAA62E56A46 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk2LBeUACgkQ4UOg/zhYFuCGeACfQIAvX4ANJdbpmPs1utCn44RU LHQAn3WiG/WYD+fN+taunZ9UF/kzgTVv =YiSa -----END PGP SIGNATURE----- --------------enigF45F6BC5412A4CAA62E56A46--