clingon icon indicating copy to clipboard operation
clingon copied to clipboard

Boolean discussion in documentation -- clarify?

Open rpgoldman opened this issue 1 year ago • 1 comments

I was working on an application of mine, and reading the documentation

In the readme:

The :boolean/true option kind creates a flag, which always returns T.

The :boolean/false option kind creates a flag, which always returns NIL.

It's not entirely clear what the above means, for a couple of reasons. In particular, it doesn't make sense for these to always return anything. I imagine what is meant is that :boolean/true is going to create an option whose value will normally be nil, unless the user supplies the flag, in which case it will be t.

Being even more fussy: these options don't "return" anything so that's why I said "an option whose value will be" instead of "returns." I believe that "returns" is shorthand for "getopt on the option name will return".

Finally, there's some confusion about how to set the :initial-value of a flag, because it seems the initial value must be either :true or :false even though what getopt gives back is either t or nil. I tried supplying t and got a somewhat cryptic error message.

rpgoldman avatar Jul 31 '24 22:07 rpgoldman

Hey @rpgoldman ,

The :boolean/true option kind creates a flag, which always returns T.

An example for this one might be an option such as --enable-engine, which when specified on the command-line will always be set to T. This is what the :flag option does internally.

The :boolean/false option kind creates a flag, which always returns NIL.

In a similar way the :boolean/false option does the opposite by setting the value associated with the option to NIL. For example --abort-on-errors option if specified might make decisions to continue with the program execution in case of errors.

These are just helper options around flags.

What you probably want to use is :boolean option which allows specifying a value. For example --enable-logging=false or --enable-logging=true.

I'd be happy to review and make changes to the documentation, if they are unclear, so feel free to propose such! :)

Thanks!

dnaeon avatar Aug 01 '24 06:08 dnaeon