From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27009 invoked from network); 26 Jun 2008 17:13:03 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 26 Jun 2008 17:13:03 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 41802 invoked from network); 26 Jun 2008 17:12:59 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 26 Jun 2008 17:12:59 -0000 Received: (qmail 14460 invoked by alias); 26 Jun 2008 17:12:56 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25252 Received: (qmail 14449 invoked from network); 26 Jun 2008 17:12:55 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 26 Jun 2008 17:12:55 -0000 Received: from vms173003pub.verizon.net (vms173003pub.verizon.net [206.46.173.3]) by bifrost.dotsrc.org (Postfix) with ESMTP id 24D5880561C2 for ; Thu, 26 Jun 2008 19:12:48 +0200 (CEST) Received: from torch.brasslantern.com ([71.121.0.2]) by vms173003.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0K3200JIIYGZT4V0@vms173003.mailsrvcs.net> for zsh-workers@sunsite.dk; Thu, 26 Jun 2008 12:12:36 -0500 (CDT) Received: from torch.brasslantern.com (localhost.localdomain [127.0.0.1]) by torch.brasslantern.com (8.13.1/8.13.1) with ESMTP id m5QHCYCj002895 for ; Thu, 26 Jun 2008 10:12:34 -0700 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id m5QHCXpA002894 for zsh-workers@sunsite.dk; Thu, 26 Jun 2008 10:12:33 -0700 Date: Thu, 26 Jun 2008 10:12:33 -0700 From: Bart Schaefer Subject: Re: PATCH: anonymous functions (no documentation yet) In-reply-to: <18441.1214488302@csr.com> In-reply-to: <200806261506.m5QF6aCd019139@news01.csr.com> To: zsh-workers@sunsite.dk (Zsh hackers list) Message-id: <080626101233.ZM2893@torch.brasslantern.com> MIME-version: 1.0 X-Mailer: OpenZMail Classic (0.9.2 24April2005) Content-type: text/plain; charset=us-ascii References: <18441.1214488302@csr.com> <9646.1214491732@thecus> <200806261506.m5QF6aCd019139@news01.csr.com> Comments: In reply to Peter Stephenson "PATCH: anonymous functions (no documentation yet)" (Jun 26, 2:51pm) Comments: In reply to Peter Stephenson "Re: PATCH: anonymous functions (no documentation yet)" (Jun 26, 4:06pm) X-Virus-Scanned: ClamAV 0.92.1/7572/Thu Jun 26 18:25:12 2008 on bifrost X-Virus-Status: Clean On Jun 26, 2:51pm, Peter Stephenson wrote: } } I just spotted that it's very easy to add "anonymous" functions, which } are defined using normal function syntax, but executed immediately. I like this idea although I prefer the "function { ... }" syntax to the empty parens with nothing before them. With FUNCTION_ARGZERO set, what's the value of $0 inside an anonymous function? What's the value of $functions[$0] ? On Jun 26, 4:06pm, Peter Stephenson wrote: } Subject: Re: PATCH: anonymous functions (no documentation yet) } } Oliver Kiddle wrote: } > f ''() { ... } } > } > might have the effect of defining a function f and running it } > immediately. And then you might write: f '' ''() { ... } and so on. } } That ought to be a relatively straightforward addition, I think, subject } to the query above. What would the form with multiple empty-string arguments mean? Call the function multiple times? (Anyway I take it from later remarks that ''() already defines a function with the empty name, so probably this "name it but also call it" idea won't work.) } > What effect does all this have on the positional parameters? } } Positional parameters from the surrounding area would be hidden and the } local parameter list empty. I could easily copy them in so that they } could be used and modified without affecting the calling environment. I'm of two minds on that score. On the one hand it'd be nice to be able to get at the surrounding $@. On the other it may often be a needless expense.