-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[CS2] Replace ‘var’ with ‘let’ everywhere (boost x2) #4255
Comments
We don't really do "compilation flags that change the generated code"... Yet. An ES6 mode has been proposed here: #4132. |
It's understandable that you are under impression of numbers, but think of what you really suggest: |
Could you explain it more detail in context of coffeescript usage? |
It's not in the case of for loops. |
It looks like CS already hoists variable declarations in loops. for a in b
c = 1
# var a, c, i, len;
#
# for (i = 0, len = b.length; i < len; i++) {
# a = b[i];
# c = 1;
# } |
This is not my field of expertise, but I would like to point one little thing. If an improvement for this is devised, perhaps In theory, since the scope of the variables is limited, it should be feasible to check statically if they are assigned once or more than once, to automatically specify I do not want to derail the current discussion. Should I open a new issue? |
If I have correctly understood your theory is not based on v8 sources nor performance tests. |
replacing all @GeoffreyBooth, this proposal might interest you |
I’m sure we could fix the REPL to work with @Inve1951, perhaps you’d like to take on the task of getting the |
This was thoroughly discussed in coffeescript6/discuss#35 and coffeescript6/discuss#58. The findings:
Based on the last point, I think function-scoped variables will always be declared with |
I made some interesting performance tests. One of them.
Calculation time : 0.570 ms.
I made same test in Babel and it was 2x time faster.
I found bottleneck. I just replaced
var
withlet
and got calculation time : 0.235 ms.As you see i get 2x speed boost only by replacing
var
withlet
.Main problem: 'let' is not supported by old browsers.
Solution: you can make this optional with compiler flag.
So can u make compile option to put
let
everywhere instead ofvar
?The text was updated successfully, but these errors were encountered: