@wycats explicit, easy to reason about. Can give V8 a better idea about potential optimizations
-
-
-
@keithwhor in what way is let harder to reason about? -
@wycats It's harder to reason about what the developer's intentions for the variable are. When you see const you know what you're getting... -
@keithwhor the developer's intention is related to whether they mutate the variable. Are you writing 100+ line functions?
End of conversation
New conversation -
-
-
@wycats it’s just more accurately describing your intention. But damn it, 5 characters vs 3! -
@mrspeaker so the worry is that you might later on forget that you *really meant* constant and mutate the binding? -
@mrspeaker Remember that `let x = 1; let x = 2;` is an error. -
@wycats Yes, but `let x=1; x=2;` is not an error while with const it is. If I don't want x to ever change, I use `const` /cc@mrspeaker
End of conversation
New conversation -
-
-
@wycats lots of opportunities for better static analysis in flow -
@nontrivialzeros why is flow able to do better static analysis if you type const vs typing let and not mutating? /cc@lbljeffmo -
@wycats@lbljeffmo Can only implement this with consthttps://github.com/facebook/flow/pull/318#issuecomment-79318314 … -
@nontrivialzeros@lbljeffmo why would flow differentiate between a variable declared const and a variable that was never reassigned?
End of conversation
New conversation -
-
-
@wycats I kind of wish const prevented shadowing, since that's my more common reassignment screwup vs in the same scope -
@modernserf in the same scope, `let` protects you unless you write `x = 1` which isn't the mistake you're ACTUALLY going to make.
End of conversation
New conversation -
-
-
@wycats the bug of being impossible for the compiler to entirely optimize out. -
@ialexi why is the compiler worse at optimizing let bindings that are never reassigned than const bindings -
@wycats it should be possible to statically analyze let and optimize it out, but if there is any single eval-like call it breaks.
End of conversation
New conversation -
-
-
@wycats Tis not a bug, tis a JIT optimization hint. -
@IDisposable I don't like talking to my JIT, and even naive JITs can identify `let`s whose binding is never mutated. -
@wycats never is a very broad brush, oft beyond the veil of a simple JIT
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.