Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is intended to replace the
Bool
flag without an inversion, as it more closely matches the underlying usage model of a flag being provided vs. not provided on the command line.This is mostly a proof-of-concept proposal as a discussion point, relating to the discussion about no-inversion
Flag
s in #170. As a summary, this proposal is intended to address the behavior of flags without inversions:As discussed in the comment linked above, in my opinion, a
Bool
doesn't represent the high-level usage model as well as anOptional
type, especially with the usage ofBool
s in flags that have inversions and can be set by the user to have bothtrue
andfalse
as a value, not onlytrue
. This PR proposes to replace the above usage with:This gains us the following benefits:
master
false
for every flag as currently on Allow normal Swift default property initialization syntax #170, while doing so in a Swift-like manner (since optionals already default tonil
, users will be familiar with this usage pattern).prefixedNo
for allBool
sHowever, this does come at a cost:
Void?
may seem strange to users that aren't "cracking the hood" of this framework, so to speak, and will likely cause some confusion that needs to be sorted out in documentationtypealias
or single-caseenum
as described in the initial discussion linked above, but I don't know of a great name for that either (Unary
?)!= nil
above)I personally feel like those benefits are worth it, but I don't think there's an exceptionally strong case for it either like there was for the default property initialization syntax in #170. Mostly, I was just curious as to what it would take to implement this and provide a concrete implementation to start off dicussion.
Checklist