From: Bakul Shah <bakul@bitblocks.com>
To: Larry McVoy <lm@mcvoy.com>
Cc: TUHS main list <tuhs@minnie.tuhs.org>
Subject: [TUHS] getopt (was Re: Any Good dmr Anecdotes?
Date: Tue, 10 Jul 2018 20:34:58 -0700 [thread overview]
Message-ID: <20180711033505.339B4156E400@mail.bitblocks.com> (raw)
In-Reply-To: Your message of "Tue, 10 Jul 2018 18:31:27 -0700." <20180711013127.GC2012@mcvoy.com>
On Tue, 10 Jul 2018 18:31:27 -0700 Larry McVoy <lm@mcvoy.com> wrote:
Larry McVoy writes:
> On Wed, Jul 11, 2018 at 10:20:50AM +1000, Noel Hunt wrote:
> > I'm surprised why anyone would bother with these routines
> > anymore, given the startling simplicity of Plan9's arg(3).
> > One stands in awe of such simplicity. I believe it was
> > William Cheswick who designed it, but I may be wrong.
plan9 arg macros are indeed very nice.
> It's nice but I like long opts. The getopt in BK (and now in L)
> looks like this and produces its own help (which does miss the
> short opts, my bad, I could fix that). Look at the default in
> the switch:
>
> string c;
> string lopts[] = {
> "bigy:",
> "date-split",
...
> "title:",
> "ysize:",
> };
>
> while (c = getopt(av, "fj:", lopts)) {
> switch (c) {
> case "bigy": bigy = (int)optarg; break;
> case "date-split": dates = 1; break;
...
> case "title": title = optarg; break;
> case "thumbnails": thumbnails = 1; break;
> case "ysize": ysize = (int)optarg; break;
> default:
> printf("Usage: photos.l");
[You can also do a switch on string in Go.]
Having to write the same strings twice is a pain. May be even
three times, if you add usage()!
I don't much like long options as they tend to proliferate.
-- Your typical engineer doesn't like to make hard choices so
indecisions turn into options!
If there have to be long options, I want to be able to
abbreviate them and I want word completion and context
sensitive help as invariably long options end up having
complex semantics.
next prev parent reply other threads:[~2018-07-11 3:36 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-29 7:53 [TUHS] " Warren Toomey
2018-06-29 10:53 ` ches@Cheswick.com
2018-06-29 12:51 ` John P. Linderman
2018-06-30 0:50 ` Steve Johnson
2018-06-30 11:44 ` Arrigo Triulzi
2018-06-30 22:42 ` Arthur Krewat
2018-06-30 23:29 ` Arrigo Triulzi
2018-07-01 4:17 ` Larry McVoy
2018-07-01 11:42 ` ron
2018-07-01 5:29 ` Dave Horsfall
2018-07-01 8:28 ` Arrigo Triulzi
2018-07-01 11:34 ` ron
2018-07-09 16:30 ` Random832
2018-07-09 17:13 ` Clem Cole
2018-07-10 5:54 ` arnold
2018-07-10 6:09 ` George Michaelson
2018-07-10 7:19 ` arnold
2018-07-11 0:20 ` Noel Hunt
2018-07-11 1:31 ` Larry McVoy
2018-07-11 1:37 ` George Michaelson
2018-07-11 1:37 ` ron minnich
2018-07-11 3:12 ` Larry McVoy
2018-07-11 3:34 ` Bakul Shah [this message]
2018-07-13 9:08 ` ches@Cheswick.com
2018-07-13 14:10 ` ron
2018-07-10 14:10 ` Clem Cole
2018-07-03 17:34 ` Perry E. Metzger
2018-06-29 23:55 ` Dave Horsfall
2018-06-30 0:06 ` Greg 'groggy' Lehey
2018-06-30 14:20 ` John P. Linderman
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=20180711033505.339B4156E400@mail.bitblocks.com \
--to=bakul@bitblocks.com \
--cc=lm@mcvoy.com \
--cc=tuhs@minnie.tuhs.org \
/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.
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).