3 ms·
There are lots of optimisations which have ultimately observable side-effects e.g. in most JS implementations the closed-over environment is optimised to just t
by masklinn 6y ago
There are lots of optimisations which have ultimately observable side-effects e.g. in most JS implementations the closed-over environment is optimised to just the free variables (and there's no closure at all if there's nothing being closed over statically), this is extremely noticeable if you drop into a debugger in the inner function because you will not be able to access any variable which wasn't closed over. Likewise, if the compiler decides to reuse part of the stackframe because it sees two variables are only used consecutively, you won't be able to access the first variable despite it still purportedly being "in scope".
- chrisseaton 6y ago> this is extremely noticeable if you drop into a debugger Is the debugger part of the language specification? No. When I say 'can you observe the difference as a programmer' you can mentally expand that to 'can you observe the difference as a programmer who is working off a copy of the language specification'. Otherwise someone armed with a debugger can look at the machine code and then we might as well say all implementation decisions are observable by the user, and then I think we're being a bit silly. > you won't be able to access the first variable I'm not familiar with this part of JavaScript off the top of my head sorry - do you mean using a debugger again here?
- masklinn 6y ago> Is the debugger part of the language specification? No. Neither is "the stack trace".
- chrisseaton 6y agoYou're mistaken - in many language it is. (I've worked professionally with multiple language specifications and implementing them.)
- deleted 6y ago[deleted]