ideas, await singular and multiple, block, try catch short hand, functioncall.catch(e) {} or .catch(e =>) #25446
Labels
Out of Scope
This idea sits outside of the TypeScript language design constraints
Suggestion
I am going to just throw this out their for debate, I may be right or I may be wrong, just few ideas, take what you like from it, just putting it out their.
Basically await allows code to look sync and simpler to follow and also by default wired up the catch forward handling to the parent caller scope. This means we then use the very verbose try{await .. } catch(e){if(x), throw x} syntax. I would like to suggest a much simpler neater syntax.
were by .catch can be called on the end of function or await function. the catch function that is called
called must return if it handles the exception otherwise it will by default be re-throw.
This depending on how implemented, could possible allow for speed up as the catch error forwarding
can be handled in the promise execution environment as long as it doesn't reference anything outside its scope. The implementation details, of the wiring could allow for delay forwarding the exception up argumented call stack. If the compiler is intelligent is could keep track of whether the statement is being called within the a nested try catch block, if their is no nested try catch block, then it doesn't need to generate forwarding code and can just call a default registered promise catch handler that was register at a global scope with the Promise library from its current execution stack, potentially gaining a speed up as the code to augment the call stacks need not be generated.
Basically one looks at loosing the .then
were , is sequences and colon is parellel execution.
Use Cases
Case A, Promise chain run in sequence
Case B, Promise chain run in parallel
Case B, Promise chain run in sequence
Case C
Case D
Case E
Checklist
50/50 means its up to were you decided to cut the optermization with regards to Promise handling.
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: