-
chevron_right
TIL that Common Lisp dynamic variables can be made locally unbound
Michał "phoe" Herda · Monday, 4 January, 2021 - 11:06 edit
;;; let's first define a global variable...
CL-USER> (defvar *foo* 42)
*FOO*
;;; ...and then make a binding without a value using PROGV
CL-USER> (progv '(*foo*) '() (print *foo*))
debugger invoked on a UNBOUND-VARIABLE in thread
#<THREAD "main thread" RUNNING {1004A684B3}>:
The variable *FOO* is unbound.
Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [CONTINUE ] Retry using *FOO*.
1: [USE-VALUE ] Use specified value.
2: [STORE-VALUE] Set specified value and use it.
3: [ABORT ] Exit debugger, returning to top level.
((LAMBDA ()))
source: (PRINT *FOO*)
0] ; look ma, locally unbound!