You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not to sound dramatic, but I'm very concerned by the fact that using breaks already existing intuitions of JavaScript syntax.
Specifically, using messes with variable declarations (let/const/var), while await using gives a false impression of awaiting something on the line it has been used (i.e. it looks like it awaits a possible promise on the right-hand side of the assignment).
Here's an example of syntax that actually fits already established conventions:
constgetResource=()=>({[Symbol.dispose/* Symbol.asyncDispose */](){/* do disposal */}});// inlineconstresource=getResource();try{/* await */resource.doSomething();}finally{/* await */resource[Symbol.dispose/* Symbol.asyncDispose */]();}// with keyword
using /* await */(constresourceofgetResource()){/* await */resource.doSomething();}// `resource` gets disposed here, clear and simple// with iteratorsconstgetIterResource=()=>({[Symbol.dispose/* Symbol.asyncDispose */](){/* do disposal */}[Symbol.iterator/* Symbol.asyncIterator */](){/* do iteration */}});for using /* await */(constresourceChunkofgetIterResource()){/* await */processChunk(resourceChunk);}
I do not claim to be qualified or provide a comprehensive and robust solution here, but at the very least this example attempts to work within already existing syntactic conventions.
The text was updated successfully, but these errors were encountered:
lichrot
changed the title
Genuine question: Why not use already existing syntactic conventions like for of ?
Genuine question: Why not use already existing syntactic conventions a-la for of ?
Jul 9, 2023
Not to sound dramatic, but I'm very concerned by the fact that
using
breaks already existing intuitions of JavaScript syntax.Specifically,
using
messes with variable declarations (let/const/var
), whileawait using
gives a false impression of awaiting something on the line it has been used (i.e. it looks like it awaits a possible promise on the right-hand side of the assignment).Here's an example of syntax that actually fits already established conventions:
I do not claim to be qualified or provide a comprehensive and robust solution here, but at the very least this example attempts to work within already existing syntactic conventions.
The text was updated successfully, but these errors were encountered: