-
-
Notifications
You must be signed in to change notification settings - Fork 36
The case for options without values #386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Knowing what this use-case is supposed to do, I'd say (I tend to think that An example of a boolean option that I could see a use-case for is something like |
Interesting. Some initial observations (don't read this as rejection, just being the devil's advocate):
I don't buy this argument. It's super common to have the value be in a variable passed at runtime--otherwise you'd just hardcode the brand name into the message. Just to be clear, an "unvalued option" means that Are you thinking about the case where the unvalued option is not a closed enumerated set? Autocompletion, for example, only works when the set is closed ("hardcoded in the function registry"). Many cases like this have value sets that evolve over time (the "product name" API I've mentioned in this group previously purposefully didn't bind to a specific set of product IDs... because we built new ones all the time) Some values will require quoted literals. So |
This was rejected in the 2024-01-08 call. In 2.0, options require values. |
TL;DR: Supporting implicit-true unvalued options would provide better UX for developers and translators and simplify validation.
Consider a function that accepts a keyword as its primary argument, say
:brand
for looking up the appropriate localized form of a brand name. Right now, this is achievable in two ways:While both of these kinda work, neither is particularly pleasant to use. If #364 is accepted, the first one improves a bit:
However, this order makes autocompletion impossible. Let's presume that the function registry is providing a known set of valid brands that may be localised, and it's only
foo-thing
. Then, by the time you've entered{fog-thing
, there's no way to know if this is valid or not because the function hasn't been identified yet. To get there, you need to type all of{fog-thing :brand}
, and then go back and fix your mistake.Using the
key=
approach is a little bit better in this regard, but really those four characters are rather superfluous, and as with the positional argument, the value might be a variable. This means that it could be valid to write{:brand key=$foo}
, and we wouldn't know until formatting time which brand we're localising. That's pretty powerful (much like dynamic message references, actually), but in many cases perhaps too powerful.Instead, I think we ought to support unvalued options, so that this becomes possible:
This has three benefits over the current alternatives:
If we don't support unvalued options, we probably ought to introduce a way that the function registry can specify that a positional argument or an option value cannot be set by a variable. Though tbh that would probably make sense independently of this.
The text was updated successfully, but these errors were encountered: