Subject: Re: What's the point of flet?
From: Erik Naggum <erik@naggum.net>
Date: Wed, 31 Oct 2001 22:10:19 GMT
Newsgroups: comp.lang.lisp
Message-ID: <3213555018873937@naggum.net>

* Francis Leboutte
| It would be nice to have the possibility to make the new binding of
| square have dynamic scope. I think an equivalent of the dynamic variable
| notion for a function defined locally would be useful in CL.

  There is a letf macro going around in various versions that can be used
  for this effect:

(letf (((symbol-function 'whatever) (lambda ...))) ...)

  It basically does

(let ((<gensym> (symbol-function 'whatever)))
  (setf (symbol-function 'whatever) (lambda ...))
  (unwind-protect
      ...
    (setf (symbol-function 'whatever) <gensym>)))

///
-- 
  Norway is now run by a priest from the fundamentalist Christian People's
  Party, the fifth largest party representing one eighth of the electorate.
-- 
  Carrying a Swiss Army pocket knife in Oslo, Norway, is a criminal offense.