-
Notifications
You must be signed in to change notification settings - Fork 1
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
Non-obvious user code execution #7
Comments
If your goal is to avoid action-at-a-distance, you'll still run afoul of Proxy traps that can cause side-effects. I don't believe we should special case |
If you consider alternate representations of
All of these will trigger getters. |
The analogy i'd apply is |
To be clear, I don't feel that strongly about this, so if the answer is just no, that's fine with me. But I do see A counter-analogy: While developing Temporal we were encouraged, particularly by implementations, to delete as many observable calls into user code as possible, in cases where the return value wasn't used or could be derived in another way (e.g., prevent |
ok, i totally agree that observable calls into user code should be minimized! but if you've made a getter and destructuring from an object with one, i think there's already expected user code. |
Yeah, fair. That is also nonlocal. I was thinking of it more in terms of, the const { foo: void, ...rest } = obj;
void obj.foo; // yes, I really do want to execute the getter
I buy that that's expected in some use cases, yes. For the use case given in the explainer, "explicitly exclude properties from rest bindings without needing to introduce throw-away temporary variables for that purpose", I would not expect or want the excluded getter to be called. Like, "I want an object with only data properties, consisting of all the properties of (But maybe that's a symptom of how my brain has been warped by diving too deep into JS's corners! I bet many people wouldn't anticipate a getter there, or write that loop, or care at all.) |
I definitely see that possible interpretation; i love the idea of preventing getter execution, but in JS i've somewhat resigned myself to the reality that the only way to prevent that is to never define getters :-) |
If I'm reading the proposal correctly, the following code snippet would execute the getter:
I'm not convinced that discarding a binding should cause this kind of action-at-a-distance in the same way that assigning a binding does. Would it be possible to make a destructuring discard binding just skip over that property, instead of executing the getter and discarding the result?
The text was updated successfully, but these errors were encountered: