Subject: Re: Function composition at run time
From: Erik Naggum <erik@naggum.net>
Date: 2000/10/19
Newsgroups: comp.lang.lisp
Message-ID: <3180969984634156@naggum.net>

* "David E. Young" <youngde@nc.rr.com>
| I was hoping I could splice these forms into a function object and
| just FUNCALL the object whenever necessary.

  Back in the old days, funcall (and friends) treated an argument that
  was a list whose car was the symbol lambda as a function.  Some
  Common Lisp implementations still do that out of courtesy to the old
  ways, but ANSI Common Lisp specifies that they should be coerced
  into functions as if by evaluating (eval `(function ,<lambda-expr>))
  before being funcallable.

| Perhaps I can't? Should I just store the forms and call EVAL at the
| appropriate time instead?

  Suppose you have a list of forms to evaluate in a variable <list>.
  (eval `(progn ,<list>)) will evaluate them in order.  If you want a
  function object, you need (eval `(function (lambda () ,<list>))),
  and then you need to funcall the result.  Unless you want to compile
  the function, as in (compile nil `(lambda () ,<list>)), of course.
  In most cases, the progn solution should be quite adequate.

#:Erik
-- 
  I agree with everything you say, but I would
  attack to death your right to say it.
				-- Tom Stoppard