by chrisseaton · 6y ago · 0 comments
The answer is probably a combination of 'they haven't gotten around to it yet', 'they don't see the need', 'they don't want the complexity', and 'they don't want to spend compile time doing that.'
Otherwise it has the same issues as const (is there a temporal dead zone violation?)
You're not doing static analysis - you're doing dynamic analysis and speculation. But this has the downsides I said - it's more complicated, it takes more time, etc.
I can understand why in a JavaScript engine there may be plenty of other concerns and it may be completely reasonable to not do the analysis, but in the common case it should (at least) be something you could do just by walking the AST, if you so desired, without even knowing the surrounding code.
Speculating that a debugger is not attached and modifying local variables, is one example.
> in the common case it should (at least) be something you could do just by walking the AST
Yes that’s why it’s speculation - handle the common cases and speculate away the uncommon cases.