Skip to content

Instantly share code, notes, and snippets.

@y2q-actionman
Created July 10, 2018 08:43
Show Gist options
  • Save y2q-actionman/0990eb4578c0af104022d9fdf176242c to your computer and use it in GitHub Desktop.
Save y2q-actionman/0990eb4578c0af104022d9fdf176242c to your computer and use it in GitHub Desktop.
clhs 3.1.2.1.1.4 は defvar された変数だと違う
http://www.lispworks.com/documentation/HyperSpec/Body/03_abaad.htm
CL-USER> (describe 'x)
X is a TENURED SYMBOL.
It is unbound.
It is globally declared to be a special variable.
It is INTERNAL in the COMMON-LISP-USER package.
; No value
CL-USER> (describe 'y)
Y is a NEW SYMBOL.
It is unbound.
It is INTERNAL in the COMMON-LISP-USER package.
; No value
CL-USER> (let ((x 1)) ;Binds a special variable X
(declare (special x))
(let ((x 2)) ;Binds a lexical variable X
(+ x ;Reads a lexical variable X
(locally (declare (special x))
x)))) ;Reads a special variable X
4
CL-USER> (let ((y 1)) ;Binds a special variable X
(declare (special y))
(let ((y 2)) ;Binds a lexical variable X
(+ y ;Reads a lexical variable X
(locally (declare (special y))
y)))) ;Reads a special variable X
3
CL-USER>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment