-
Notifications
You must be signed in to change notification settings - Fork 32
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
Stage 3 Specification Review: Waldemar Horwat #71
Comments
The readme states that multiple exceptions are handled as:
whereas the semantics seem to unconditionally create an AggregateError if any disposers produce errors. I like the version in the semantics much better. However, it still suffers from the potential issue that if you have several consecutive |
A DisposableResource's [[DisposeMethod]] can't be
A
I'll add a table describing the values, as well as make them clearer:
I agree. The current logic is a best effort to avoid a blanket function f() {
- const resource = ...;
- try {
+ {
+ using const resource = ...;
...
}
- finally {
- resource.close();
- }
return f();
} Handling fall-through for cases in a
Ah, I neglected to ban I explicitly ban it in
The README is out of date in this case. I will update it shortly. |
Also, regarding function f() {
switch (x) {
case 1:
return f(); // probably tail callable
case 2:
using const y = ...;
// falls through
case 3:
return f(); // possibly not a tail callable?
}
} Even if we could solve for |
I addressed the above comments in #75. You find the rendered version of the spec with these changes here: https://tc39.es/proposal-explicit-resource-management/pr/75 |
That's always a possibility (and is already possible with In .NET, the |
I don't like the "[lookahead ≠ using]" restriction in the for-in rule of the grammar because it makes the grammar non-LR(1). The issue is that there are two parallel productions that start with "for (ForDeclaration[?Yield, ?Await]", one of which has the "[lookahead ≠ using]" restriction and one which doesn't, which causes a grammar conflict on how the ForDeclaration should be parsed. If you want to syntactically outlaw |
We already do something similar in ForInOfStatement with respect to how LeftHandSideExpression is treated in If
The same could be said for LeftHandSideExpression, and I doubt we want to refactor that. |
Also, refactoring ForDeclaration might require a number of additional changes to SDOs that reference it currently. I'd argue the lookahead restriction is actually simpler for the narrower case of banning |
|
I've updated the lookahead to |
Given a choice between a complex lookahead and a plain production, the plain production is much better. The I don't see any significant problem with SDOs and abstracting LetOrConstForDeclaration out of ForDeclaration. If there is one, what is it? |
Wouldn't we need to change all of these to support that refactor? |
These seem like trivial updates. They're either just trivial passthroughs or change ForDeclaration to LetOrConstForDeclaration. |
ForStatement: "Let LexicalDeclaration Contains UsingConst, return contains-using-const." → "If LexicalDeclaration Contains UsingConst, return contains-using-const." Also note that this definition is fairly brittle. It works for now but will break if do-expressions land in the language. |
The refactoring hazard issue I raised at the meeting hasn't been addressed yet.
has observably different behavior when exceptions are thrown from:
We should make the behavior the same. One way to do this is to avoid merging multiple errors from the same scope together into a single |
Why should we make them the same? |
Because a reader of those two snippets of code would not expect them to have different behavior. |
Why wouldn't they? Two different scopes have different behavior wrt const/let, and certainly would with the scope of |
Well, let me make a weaker claim: I definitely would not expect those two snippets of code to have different behavior. I strongly suspect many readers will share my intuition, regardless of how reasonable it is. |
Just to clarify my understanding, it's only the shape of the error that would diverge, right? All disposal would still be performed, in the same order, regardless of any error occuring during disposal. And all errors would still be available, just through a different path (flat |
Since it already has to lookahead, I guess it's not too problematic for implementors to add another case |
That is correct, the only difference would be in the shape of the AggregateError. All other errors would still be reachable. |
@waldemarhorwat: I'd appreciate another look at the specification text prior to the September meeting, if possible. |
Has the refactoring hazard issue been fixed? See the proposed fix above, which as far as I can tell has not been implemented. |
The jagged AggregateError fix has not been implemented in the version of the spec I can see. |
The change can be found here and is waiting for review: #117 |
Thank you for the link. The proposal looks good with the change in #117. |
#117 has merged, along with a few other minor issues noticed by @zloirock. @waldemarhorwat, should I consider this sign-off on the proposal specification text? |
This is a placeholder task for the Stage 3 Specification Review feedback from Waldemar Horwat (@waldemarhorwat), per https://github.com/tc39/notes/blob/master/meetings/2019-07/july-25.md#explicit-resource-management-for-stage-2-continuation-from-tuesday
The text was updated successfully, but these errors were encountered: