Subject: Re: Maintaining multivariable state (newbie question)
From: (Rob Warnock)
Date: Sat, 25 Aug 2007 20:21:50 -0500
Newsgroups: comp.lang.lisp
Message-ID: <>
Scott Burson  <> wrote:
| Robert Uhl <> wrote:
| > So: (let ((context (copy-context=with-variations +FOO-context+
| >                                                :add-1 t
| >                                                :colour nil)))
| >        (FOO BAR context))
| > is cleaner than:
| >   (let ((*FOO-add-1* t)
| >         (*FOO-colour nil))
| >        (FOO BAR))
| () If I ever need to delay some operation by wrapping it in a lambda
| and calling the resulting function later, the first form will behave
| predictably and the second won't.

Sure it will, if you wrap the LAMBDA around the binding form too:

    (lambda ()
      (let ((*FOO-add-1* t)
	    (*FOO-colour nil))
        (FOO BAR)))

Or if you're worried about more parameters than those, you could
always do something along these lines [which I confess I have done
on certain rare occasions]:

    (let ((later-add-1 t)
	  (later-colour nil)
	  (later-style *foo-style*)
	  (later-font *foo-font*)
	  (later-weight *foo-weight*))
      (lambda (bar)
	(let ((*foo-add-1* later-add-1)
	      (*foo-colour* later-colour)
	      (*foo-style* later-style)
	      (*foo-font* later-font)
	      (*foo-weight* later-weight))
	  (foo bar))))


Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607