Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative design is
We have the same design in
ForOfStatement
. However, in this case, the other kinds, namelyvar
,let
andconst
do not have await counterparts. So I figure it would be more efficient to pack theawait
flag into thekind
string.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like the correct course of action given that constraint.
Would we also have a
kind: "using"
for sync disposal?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we already have https://github.com/estree/estree/blob/master/stage3/explicit-resource-management.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! I think my only question then is, in the final version, do we want
kind: "using await"
instead ofkind: "usingAwait"
to match the actual syntax?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I slightly prefer
usingAwait
orasyncUsing
if other syntax is adopted, because "camelCase" is slightly shorter than "camel case". I think we can trust TC39 thatusingAwait variable
will never be approved alongside theusing await variable
, so eitherkind: "using await"
orkind: "usingAwait"
should be good.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm slightly more in favor of
kind: "using await"
to have it more closely match the actual syntax. I was also looking through the spec, and it seems like we don't have other instances of string values in camel case. Though, to be fair, we also don't have other instances of string values with spaces, so that's probably not a great argument. :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I think I’m more in favor of “using await” to match actual syntax. This is important for code generators that take in the AST and output source code. If we use “usingAwait”, every code generator will need to be updated to catch this special case. With “using await”, no changes will be necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have strong preference. Either
"using await"
or"usingAwait"
is fine. I am waiting for resolution of the next meeting, since we may have to change that again if"async using"
, after that I will go with your approach.Speaking of code generator, if they don't handle edge cases like
using /* feeling lucky */ await foo = ...
, they can proceed with printingnode.kind
as-is.