by franciscop · 6y ago · 0 comments
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.
A debugger can do anything. You can't outthink a debugger and shouldn't try.
> Yes that’s why it’s speculation - handle the common cases and speculate away the uncommon cases.
Speculation is when you guess and need to have a guard in case the guess is wrong. They're describing a situation where it can't be wrong and you wouldn't need to speculate.