-
Notifications
You must be signed in to change notification settings - Fork 49
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
New principle: Guidance on options dictionaries and default values #391
Comments
From today's breakout:
Will discuss again in plenary. |
If all callers want numeric it should indeed have been |
I really like this wording!
|
One of those docs says
and I think that's basically wrong? A string-taking API should not be required to use the default value Rather, the way I'd put it is that an explicit (That rule appears to have been introducing in #228.) I agree with the OP that "reasonable defaults should be weighed more highly than all of the above". Not sure it's going to be possible to be any more precise about what "reasonable" means, though. It's not just a matter of which use case is more common - for example, if there's a potentially destructive API, I would want the default to be non-destructive even if in practice the destructive one comes up more. We could maybe collect some heuristics, though. Footnotes
|
@bakkot Nice catch (wrt the sentence about |
Opened #437. |
This came out of this Twitter thread which started from my observation that in
Intl.Collator
, thenumeric
option isfalse
by default, which is rarely what you need.Currently the only guidance we have wrt options dictionaries is this:
Which basically tell API designers to:
false
is the defaultoptionName: false
becomes a confusing double negative).There's also a naming principle about preferring common words for names, though nothing about avoiding overly long names.
All good goals, but I think what a "reasonable" default is needs to be more explicitly defined (and needs to take into account % of use cases that would have needed to specify that value), and having reasonable defaults should be weighed more highly than all of the above, when there's no way to satisfy them all. If a boolean parameter is designed in such a way that
false
is the default, and the name is positive, but it needs to be specified in nearly every API invocation because this default actually only works for edge cases, that's not a great API IMO.The text was updated successfully, but these errors were encountered: