[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: compiling interpreted functions



In article <28ith7$t8n@pan.ics.uci.edu>, pazzani@pan.ics.uci.edu (Michael Pazzani) writes:
|> I'm having a problem storing functions in structures, and I hope
|> someone can help clarify this for me.  [...]
|> 
|> I've defined a simple structure and macro to illustrate the problem:
|> 
|> (defstruct r fun)
|> (defmacro macro(X) `(defparameter ,x (make-r :fun #'(lambda() ',x))))
|> 
|> Now, if I compile a file that has a call to the macro:
|> (macro one)
|> and load the file , everything works fine, as one would expect: [...]
|> If the form is entered at top level to lisp, everything
|> works fine also: [...]
|> However, as 16 points out, this isn't compiled, so I'd like
|> to compile it.  However, I can't figure out how to compile it:
|> 
|> USER(18): (setf (r-fun two) (compile nil (r-fun two)))
|> Error: Illegal syntax for function: #<Interpreted Function (unnamed) @ #x6e9cee>
|> 

I believe that COMPILE takes either a lambda expression '(lambda()..) or a function name,
and your function argument is neither (it's a function), so the error is appropriate.

If you want to get the function compiled when running in an interpreted mode,
you need to up the level of your call to compile:

USER: (funcall (compile nil '(lambda()(macro one))))


Hope this helps,

-Kelly Murray