From: Peter Stephenson <pws@csr.com>
To: "Nikolai Weibull" <now@bitwi.se>
Cc: "Zsh hackers list" <zsh-workers@sunsite.dk>
Subject: Re: Advantages of using _argument states
Date: Wed, 15 Nov 2006 10:27:23 +0000 [thread overview]
Message-ID: <20061115102723.1a7e75d9.pws@csr.com> (raw)
In-Reply-To: <dbfc82860611141329o354dac37p3e574a23581f2fc1@mail.gmail.com>
"Nikolai Weibull" <now@bitwi.se> 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 <pws@csr.com> 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
prev parent reply other threads:[~2006-11-15 10:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-14 21:29 Nikolai Weibull
2006-11-15 10:27 ` Peter Stephenson [this message]
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=20061115102723.1a7e75d9.pws@csr.com \
--to=pws@csr.com \
--cc=now@bitwi.se \
--cc=zsh-workers@sunsite.dk \
/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).