I want a programming language that takes dynamic scope seriously. Not because I think it would be good, but I think it would be interesting.
Additionally, Kernel has dynamic binding built-in, and done in a nice way. You never explicitly access a dynamic variable but you only have an accessor function to it. A new scope is created when binding a dynamic variable, and the accessor will return whatever was bound anywhere in the dynamic extent of this scope.
($define! (with-str get-str) (make-keyed-dynamic-variable))
($define! f
($lambda ()
(print (get-str))))
(with-str "Hello, world!"
($lambda ()
(f)
(with-str "Goodbye, world!" f)
(f)))
Prints "Hello, world!" "Goodbye, world!" "Hello, world!"Perhaps the only downside to this is that a runtime error will be raised if `get-str` is called before a value is bound. I think it would be a bit nicer to include a default binding as an argument to the call of `make-keyed-dynamic-variable`.
;; -*- mode: Emacs-Lisp; lexical-binding: t; -*-
You can then opt into dynamic scope for single variables, when it makes sense: (defvar variable)