<B/>

Dynamic Scoping

The one unambiguously bad design choice in programming languages.
Started Last edited
Racket
Lisp
Programming Languages
Lexical Scoping

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.

dyn-scope.rkt
#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:

64

Well, this is bad.