20. Advanced topics:
defvar, defparameter, defconstant
DEFVAR
豐蠍 螳
(defvar *total-glasses*)
覯 蠏 螳 碁覃 defvar襯 牛伎 覦蠖
> (defvar *total-glasses* 0
"Total glasses sold so far")
> (defvar *total-glasses* 3
"Total glasses sold so far")
> *total-glasses*
0
DEFPARAMETER
豐蠍 螳螻 蟷 伎
(defparameter abc 10)
碁 螳 defparameter襯 牛 覦蠖
> (defparameter *max-glasses* 500
"Maximum number of glasses we can make")
> (defparameter *max-glasses* 300)
> *max-glasses*
300
defvar defparameter 螳 覓碁 蟲譟一伎襷 defparameter 襦蠏碁 ろ 覲讌 螳
DEFCONSTANT
襷れ伎 覦讌
Lisp special valiableれ 蟯旧朱 *襦 語 讌襷 defconstant 碁ゼ
Lisp PI 螳 伎 れ
21. Advanced topics:
Rebinding special variables
Function 語
語襯 special 覲 企朱 讌 語 rebinding
(defun print-in-base (*print-base* x)
(format t "~&~D is written ~S in base ~D."
x x *print-base*))
> (print-in-base 2 205)
205 is written 11001101 in base 2.
NIL
LET
LET 牛 覦碁
(defvar *foo* 2)
(defun bump-foo ()
(incf *foo*))
(defun rebind-boo ()
(let ((*foo* 100))
(incf *foo*)
(bump-foo)))