Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

HasProperty + Get combo doesn't seem right for option bags #36

Closed
domenic opened this issue Jul 16, 2021 · 2 comments
Closed

HasProperty + Get combo doesn't seem right for option bags #36

domenic opened this issue Jul 16, 2021 · 2 comments

Comments

@domenic
Copy link
Member

domenic commented Jul 16, 2021

https://tc39.es/ecma402/#sec-getoption is what Ecma 402 does: only a single Get(), with a default if the result is undefined. https://heycam.github.io/webidl/#es-dictionary similarly for the web platform.

The dual step means you'll trigger double the meta-object protocol traps. This is mostly a theoretical concern since if you have a weird proxy where [[GetOwnProperty]] and [[Get]] disagree, you're screwed anyway. But it feels inelegant.

However that doesn't seem to account for your desired semantics of distinguishing present vs. undefined-but-not-present. I argue in #35 this is bad semantics, so I think that'd be the best way to fix this :). I'm not sure if there are any others.

@bakkot
Copy link
Contributor

bakkot commented Jul 16, 2021

See prior discussion here and here.

To summarize, I think that just doing Get is reasonable for most options bags, because undefined is not a sensible value for the option and so can be treated equivalently to the option being unspecified, but if we are distinguishing between new Error('foo') and new Error('foo, { cause: e }) in general (cf #35) then we should still do so when e happens to be undefined.

@legendecas
Copy link
Member

Closing as the proposal has reached consensus to stage 4.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants