HACKER Q&A
📣 mardiyah

What are dynamical scope advantages?


What actually are dynamical scope advantages over lexical/statical one with respect to compilation, runtime and others low-level efficiencies ?

a direct, easily seen edge to us as coders is the better readability, being less fussy argument/parameter passing


  👤 PaulHoule Accepted Answer ✓
Every so often I like to ‘break the rules’ and write functions that look up the stack to find variables that they should not normally have access to. (TCL and Python are notorious being able to do this, C also if you are inzane.)

One range of applications is when you are writing a set of functions intended for interactive use in the REPL and you want to keep context between them. These days though I use contextvars to do that, in the JVM world thread local variables are a great way to do that (Clojure uses them to set numeric precision.)