[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gcl-devel] (random tester) Error in FUNCALL [or a callee]: Caught f
Paul F. Dietz
Re: [Gcl-devel] (random tester) Error in FUNCALL [or a callee]: Caught fatal error [memory may be damaged]
Wed, 26 Nov 2003 22:26:48 -0600
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624
Camm Maguire wrote:
One day I'd really like your and others advice on some lisp
programming dos and donts. In particular, I frequently don't
understand why global special variables are used in place of
explicitly passed arguments. My understanding of the rules governing
lexical and dynamic binding are still a bit primitive, with the latter
in my mind basically being equivalent to protecting a body of code
with an assignment to a C global and a save of the original value on
entry, and a restore of the old value on exit.
Special variables get used when the value of the variable rarely
changes. Parameters are used when the values change frequently.
One can combine the two styles by making a function's lambda
parameter be a special variable:
(defun foo (x *y* z)
(declare (special *x*)) ;; a prior toplevel (declaim (special *x*))
;; would also work
;; The 2nd value passed to FOO will become the value of a binding
;; to the special variable *y* for the life of this call.