logoalt Hacker News

alexey-salmintoday at 5:48 AM0 repliesview on HN

>> After all, a debugger can track what variable goes where at every line of code, so this can be done.

> Variable value tracking breaks down pretty much the moment any optimization happens.

I think for nested functions it's not [only] a question of performance/optimizations but of correctness. Even if you properly unwind the stack like a debugger trying to find the parent frame, you may actually find multiple due to recursion. It's impossible to know which one is "yours" unless at least some information about the parent frame was passed to the nested function at invocation time. It can't be a truly static function.