Skip to content
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

Drop 'const' from 'using' declarations #87

Merged
merged 3 commits into from Aug 5, 2022
Merged

Drop 'const' from 'using' declarations #87

merged 3 commits into from Aug 5, 2022

Conversation

rbuckton
Copy link
Collaborator

This drops the const keyword from using declarations to reduce confusion over the fact BindingPattern is disallowed.

@github-actions
Copy link

A preview of this PR can be found at https://tc39.es/proposal-explicit-resource-management/pr/87.


// or, if `handle` binding is unused:
using const void = acquireFileHandle(); // block-scoped critical resource
using void = acquireFileHandle(); // block-scoped critical resource
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using void = acquireFileHandle(); // block-scoped critical resource
using acquireFileHandle(); // block-scoped critical resource

Is it possible?

Copy link
Collaborator Author

@rbuckton rbuckton May 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. `using` AssignmentExpression would conflict with using(x) (which is already legal JavaScript). The other point of using void = was that it could be used in a BindingList:

using x = ...,
      void = ...,
      y = ...;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

`using` AssignmentExpression would conflict with using(x) (which is already legal JavaScript).

That is, unless we did something like `using` [lookahead != `(`] LeftHandSideExpression `;`, however I could see potential uses like the following that wouldn't work with the above:

using void = resource ?? getResource();

or

using void = (resource ??= getResource());

@rbuckton rbuckton merged commit 13b77e2 into main Aug 5, 2022
@rbuckton rbuckton deleted the dropConstKeyword branch August 5, 2022 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants