-
Notifications
You must be signed in to change notification settings - Fork 101
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
Clarify getting a key that does not exist from a map #179
Comments
I've been using nothing in whatwg/xhr#176. It is somewhat awkward to do an exists test first. Is it really bad to have some special values that make things more convenient? E.g., the reason I like failure a lot is that you then don't have to try/catch things. Just branch on the return value and carry on. |
I think having null, undefined, failure, and nothing is way too many... That example you gave seems straightforward to replace with an exists tests, unless I'm missing something? It doesn't even use the returned value. |
Way too many? What else do you want to get rid of? Agreed that we can probably drop "nothing" though. I misremembered. |
I'm not sure we can get rid of the others, although we can limit undefined to just the cases where we need to directly interface with JS (and, as such, not make it an Infra concept). But having 2 in Infra/3 in the platform already feels like too many, thus not wanting to add another :) |
Note that we also have "argument not given" which is arguably also a special value. |
Contrast lists:
with maps:
I think we should say "must not" and disallow out-of-bounds keys in both cases, requiring you to test with "exists" first.
An alternative is to define "nothing" to mean some special no-value, but the web has enough of those already (null, undefined, some specs use "failure") so I'd rather not do that.
Thoughts? Happy to whip up a PR if people agree. /cc @mkruisselbrink; this came up in w3c/FileAPI#92 (comment)
The text was updated successfully, but these errors were encountered: