Is there any way to compile an unnamed lambda function? For example, I
have a list of lambda expressions that are created at runtime and
executed in order (inside a DOLIST). However, this is done for quite
some time and I'd like to speed it up a bit.
(setf foo #'(lambda (x) (1+ x))) => FOO
(compiled-function-p foo) => NIL
This is in LispWorks. I was hoping there was a simple way to force
these lambdas to compile when they were created. Since they are
unnamed, I can't use COMPILE. Hopefully I'm just missing the knowledge
of some other CL function ;)
Jeff M.
--
(surf-to "http://www.retrobyte.org/")
In article <····················@attbi_s52>, "Jeff" <·······@gmail.com>
wrote:
> Is there any way to compile an unnamed lambda function? For example, I
> have a list of lambda expressions that are created at runtime and
> executed in order (inside a DOLIST). However, this is done for quite
> some time and I'd like to speed it up a bit.
>
> (setf foo #'(lambda (x) (1+ x))) => FOO
> (compiled-function-p foo) => NIL
If you compile the file that contains the above lines, it should return
T.
>
> This is in LispWorks. I was hoping there was a simple way to force
> these lambdas to compile when they were created. Since they are
> unnamed, I can't use COMPILE. Hopefully I'm just missing the knowledge
> of some other CL function ;)
Why can't you use COMPILE? Its optional argument is the interpreted
function that should be compiled:
(setq foo (compile nil foo))
--
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Barry Margolin wrote:
> Why can't you use COMPILE? Its optional argument is the interpreted
> function that should be compiled:
>
> (setq foo (compile nil foo))
Sweet. I knew I was just missing something simple. Thanks :)
--
(surf-to "http://www.retrobyte.org/")
"Jeff" <·······@gmail.com> writes:
> Is there any way to compile an unnamed lambda function?
(setf foo (compile nil #'(lambda (x) (1+ x))))
(setf foo (compile nil `(lambda (x) (,operator x))))
Or, if you put (setf foo #'(lambda (x) (1+ x))) in a file or
function and COMPILE-FILE or COMPILE that, then the lambda will
also get compiled. (I dont know if there are exceptions to this.)