Saturday, January 21, 2006

Using let outside functions

I was writing defvars for functions that needed to share state information.

(defvar *splitlevel* 0)

(defun foo ()
(do something with *splitlevel*))

(defun bar ()
(do something else with *splitlevel*))

I've now found the use of let to wrap up several functions at once:

(let ((splitlevel 0))
(defun foo ()
(do something with splitlevel))

(defun bar ()
(do something else with splitlevel)))


Post a Comment

<< Home