Lexical vs Dynamic Scoping
Comments debate lexical scoping versus dynamic scoping in programming languages such as Python, JavaScript, Lisp, and Emacs Lisp, focusing on closures, variable binding, and scope resolution behaviors.
Activity Over Time
Top Contributors
Keywords
Sample Comments
... is this a joke? It's called lexical scoping, and it's supported by more languages than not.
What is proper lexical scoping? Does JavaScript get it right?
With no scoping you don't, because there is no inner scope.With dynamic scoping you also don't, because there is no lexical scope.What am I misunderstanding?
Yes, it's called dynamic scoping, and for a long time it wasn't believed that the other option (what we call lexical scoping today) could even be implemented efficiently.https://en.wikipedia.org/wiki/Scope_(computer_science)#Dynam...
you have reinvented dynamic scoping :).
Isn't this similar to dynamic scope?
I see now, they have mutable variables, within a lexical scope anyway.
That scope logic is normal in many interpreted languages. I love it in Python.
This is the classic lexical vs dynamic scoping. Dynamic scoping works great until it doesn't.
This is know as dynamic scope, as opposed to lexical scope: https://en.wikipedia.org/wiki/Scope_(computer_science)#Lexic...