[m-dev.] Getopt extension for discussion
Fergus Henderson
fjh at cs.mu.oz.au
Tue Apr 22 10:43:20 AEST 1997
Thomas Charles CONWAY, you wrote:
>
> I was talking with Philip the other day, and he asked for a "maybe string"
> option type so that you can have:
> --opt "a string"
> or --no-opt
>
> He argued that this was better than using the empty string as a sentinel
> for the "no" case. The example application was filenames (in which case
> "" would always be a valid sentinel). Following is a diff that adds the
> requested functionality.
>
> Can anyone give a realistic example where "" is not a valid sentinel, where
> the maybe string option would be a real advantage?
I had a brief chat with Philip yesterday, and he convinced me that
this is a worthwhile change. I'd be happy with using "" as a sentinel,
so long as only the developer has to know about it. But Philip has
examples where the default string is non-empty (e.g. a configuration
file may default to "/etc/foo"), but the user can disable the option.
It's not so bad for a developer to set the default to "", but its
pretty ugly if the user has to know about the sentinel.
> -% We support four different option types: bool, int, string, and
> +% We support four different option types: bool, int, string, maybe-string
s/four/five/
s/maybe-string/maybe_string/
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
More information about the developers
mailing list