News for hackers. Stuff that matters.
Re:Closures and Objects Are Equivalent (2013) by fulafel on Sunday November 20, 2022 @02:46AM (#33679149)
GCC C nested functions do have access to outer lexical scopes: http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Nested-Functions...

But dynamic scope is a wholly another thing, most languages with closures don't have it. One exception I know is Clojure where you can declare variables explicitly as dynamically scoped, and it can be used eg as an alternative to passing around a context map when handling requests in a server style program. (And Elisp had dynamic scoping first, then closures added as a add-on feature)

Re:Closures and Objects Are Equivalent (2013) by thelopa on Sunday November 20, 2022 @05:45AM (#33679913)
In Common Lisp, all globals are dynamically scoped. Lexical scoping only exists in limited scopes (e.g. a function body). There are non-standard extensions provided by many compilers to expose lexical globals. You can also kind of hackily create your own “lexical global” using a simple symbol macro, but it has some serious caveats.