From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5080 invoked from network); 15 Nov 2006 10:29:03 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.7 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 15 Nov 2006 10:29:03 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 78574 invoked from network); 15 Nov 2006 10:28:56 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 15 Nov 2006 10:28:56 -0000 Received: (qmail 6557 invoked by alias); 15 Nov 2006 10:28:52 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23000 Received: (qmail 6545 invoked from network); 15 Nov 2006 10:28:50 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 15 Nov 2006 10:28:50 -0000 Received: (qmail 78193 invoked from network); 15 Nov 2006 10:28:50 -0000 Received: from cluster-c.mailcontrol.com (168.143.177.190) by a.mx.sunsite.dk with SMTP; 15 Nov 2006 10:28:46 -0000 Received: from rly19c.srv.mailcontrol.com (localhost.localdomain [127.0.0.1]) by rly19c.srv.mailcontrol.com (MailControl) with ESMTP id kAFASPt6004571 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 15 Nov 2006 10:28:35 GMT Received: from submission.mailcontrol.com (submission.mailcontrol.com [212.158.48.250]) by rly19c.srv.mailcontrol.com (MailControl) id kAFARSXJ002237 for zsh-workers@sunsite.dk; Wed, 15 Nov 2006 10:27:28 GMT Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly19c-eth0.srv.mailcontrol.com (envelope-sender Peter.Stephenson@csr.com) (MIMEDefang) with ESMTP id kAFAROmx002054; Wed, 15 Nov 2006 10:27:28 +0000 (GMT) Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.1830); Wed, 15 Nov 2006 10:27:23 +0000 Date: Wed, 15 Nov 2006 10:27:23 +0000 From: Peter Stephenson To: "Nikolai Weibull" Cc: "Zsh hackers list" Subject: Re: Advantages of using _argument states Message-Id: <20061115102723.1a7e75d9.pws@csr.com> In-Reply-To: References: Organization: Cambridge Silicon Radio X-Mailer: Sylpheed version 2.2.9 (GTK+ 2.8.20; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 15 Nov 2006 10:27:23.0744 (UTC) FILETIME=[A3B13E00:01C708A0] X-Scanned-By: MailControl A-07-06-70 (www.mailcontrol.com) on 10.67.1.129 "Nikolai Weibull" wrote: > As far as I can tell, the only difference (and an obvious one at that) > is that states result in a big case-statement but you avoid extra > functions, whereas writing a function adds an extra function, but > saves us from the big case-statement. > > I've gone over the documentation a bunch of times and I've been > looking through completion definitions without seeing any point to > using states over functions. > > Am I correct in my assessment that they're basically two ways of doing > the same thing and the difference between them is the one I wrote > about above? There's no hidden piece of magic in states beyond what's documented, no. Potentially they allow more complicated logic inline: _arguments 'blah:blah:->blahstate' && return 0 blah blah blah any old stuff case $state in (blahstate) blah blah && return 0 # could run _blah here, of course ;; esac blah blah some other stuff If you'd used a function then you'd have had to bury the extra logic in the function or at the end of the _arguments line (_alternative or whatever). If your particular case doesn't have any of these complications then a function is probably neater. -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php