Open kghost opened 5 years ago
There is already some language only support expressions, and no statements at all, like scala.
I have seen that one purpose do does is that convert statements to expressions, but why can't we push it further, that let it eliminate ALL statements
do
collect all loop result will cause performance issue when running legacy codes
do { for (const x of y) z(x) } -> y.foreach(x => z(x)) : undefined
so maybe another do is needed:
do { for (const x of y) do { z(x) } } -> y.map(x => z(x)) : generator(typeof z(x))
do { try x catch(e) y finally z } -> { try return x catch(e) return y finally z }
return finally if inside do:
do { try x finally do z } -> try x finally return z }
Looking for your help !
We can eliminate all statements, convert all of statements to expressions to make our javascript life better
Movation
There is already some language only support expressions, and no statements at all, like scala.
I have seen that one purpose
do
does is that convert statements to expressions, but why can't we push it further, that let it eliminate ALL statementsFOR statement
collect all loop result will cause performance issue when running legacy codes
so maybe another do is needed:
TRY statement
return finally if inside do:
More statements ...
Looking for your help !
Conclusion
We can eliminate all statements, convert all of statements to expressions to make our javascript life better