Subject: Re: Midfunction Recursion
From: Erik Naggum <>
Date: 24 Oct 2002 18:42:10 +0000
Newsgroups: comp.lang.lisp
Message-ID: <>

* Steven E. Harris <>
| It's not yet intuitively evident to me, but I'd like to get to the point
| where it is. I consulted the HyperSpec on DO and found this clause:

  Investigate what the standard has to say on /bindings/.

| If so, how could one force the capture of the current value of /i/ to
| eventually present (4 3 2 1)?

  As you would capture any other value in a closure, create a binding and a
  closure over it.  E.g., to return a function that captures a binding:

(let ((x <initial>))
  (lambda (&optional (new nil new-p))
    (if new-p 
        (setq x new)

  Call the returned function with a value to set the value of the binding,
  with no value to return the initial or last set value.

  A more Common Lisp way to do the same would be

(let ((x <initial>))
  (defun x ()
  (defun (setf x) (new)
    (setq x new)))
Erik Naggum, Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.