Dynamic Scoping
The one unambigiously bad design choice in programming languages.
Started 17 hours ago
Last edited 17 hours ago
Lexical Scoping refers to when the location of a function’s definition determines which variables you have access to. On the other hand, Dynamic Scoping uses the location of the function’s invocation to determine which variables are available.
#lang smol/dyn-scope-is-bad
(defvar y 2)(deffun (times-2 x) (* y x))
(let ([y 3]) (times-2 2))(times-2 2)Evaluation:
64Well, this is bad.