On Tue, 10 Jul 2018 18:31:27 -0700 Larry McVoy <lm(a)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.