From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10403 invoked by alias); 24 Mar 2011 11:59:29 -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: 15888 Received: (qmail 22213 invoked from network); 24 Mar 2011 11:59:27 -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=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.212.43 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=6xv6W/Dn5pRXBgshz8NPaV85auRPX0QyWjNYgJv9OI4=; b=oiIRh53MVS1YdRIlpmpV0QfvBVDznLEJIufd7FgS1+Ags/yoy92oLAiXJvGC9diqZb /6clYPANIKxUSb6bGaU2CogDSy/HK/uYQn9MtLj2VqyQpZ+pcCgK50Fnu3tlZFt6YdhZ K7voQRflDjvRLAjnEKeynjB6MLouu3EOL1eCE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=f43o7l+ziLtpkXY9843EzKW+Cl7wkDy6nMrEjyxBlIPmf4T0ccXIS7IhU+PCRw41Gf PCLDW8Ei7ck7sYZKJ7A326sgNfC4We/OHnYUrPjvIZyZkOhOWuS+OTiRmMT3DDEwLuEA vEr38BhG6niL4wun8LiHlGflgrjj45Rmx4gzg= MIME-Version: 1.0 In-Reply-To: <4D8B1128.2090405@necoro.eu> References: <4D8A810A.3050300@necoro.eu> <4D8B1128.2090405@necoro.eu> Date: Thu, 24 Mar 2011 12:51:19 +0100 Message-ID: Subject: Re: Local inner functions From: Mikael Magnusson To: =?UTF-8?Q?Ren=C3=A9_=27Necoro=27_Neumann?= Cc: zsh-users@zsh.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 24 March 2011 10:38, Ren=C3=A9 'Necoro' Neumann wrote: > Am 24.03.2011 02:41, schrieb Bart Schaefer: >> On Wed, Mar 23, 2011 at 4:23 PM, Ren=C3=A9 'Necoro' Neumann > wrote: >>> >>> foo () >>> { >>> bar () { } >>> } >>> >>> Is there some way of making 'bar' to be local to 'foo'? Using the >>> 'local' keyword does not work :). >> >> The short answer is "no." And you can't make local aliases either. >> >> The slightly longer answer is that there are a couple of ways to fudge >> it, of varying degrees of hackishness. > > Thanks for your answer. Instead of your 'always'-block, I tried > trap 'unfunction bar' EXIT - but of course this is no good in case of > name clashes :). > > So, if nothing like this really works (and local functions are not been > to be implemented into zsh), I'll just use the $0_bar approach (wasn't > aware of this), to at least reduce the chance of clashes. If your function doesn't need to modify the parent environment in any way, you can simply run it in a subshell: function bar() { echo stuff } function foo() { ( function bar() { echo whatever } bar ) } foo bar --=20 Mikael Magnusson