It is a question about variable bind in function define:
If I define funcion "total" like this,x in "total" is bind to the local x in let.
CL-USER> (let ((x 0))
(defun total (y)
(incf x y)))
TOTAL
CL-USER> (defvar x 10000)
X
CL-USER> (total 1)
1
but,if I define "total" like this,x is bind to global x in defvar:
CL-USER> (defvar x 10000)
X
CL-USER> (let ((x 0))
(defun total (y)
(incf x y)))
TOTAL
CL-USER> (total 1)
10001
Why this? I need an explanation to understand it. the environment is windows+emacs+slime+sbcl.Thanks.