On Wed, Oct 13, 2004 at 04:03:57PM +0200, Gerhard Schellhorn wrote: > (lambda (x) > (if (eq (car x) 'g) (g (cadr x)) `(h ,(cadr x))))
So you are expecting the call to be like this?: (f '(g t)) Or does (g t) return (G T)? > (defun comp (f lambdaexp) > (if (heuristis-says-compile f) > (compile f lambdaexp) > (setf (symbol-function f) lambdaexp))) Something doesn't seem right here. What is the type of lambdaexp? I suspect you are trying to set the symbol-function of f to a list. That is not valid. In Common Lisp, functions are of type FUNCTION. If you have a list that you want to turn into a function, you have 3 options: (eval list) => #<FUNCTION> (compile nil list) => #<FUNCTION> (coerce list 'function) => #<FUNCTION> In addition, there is no way to guarantee that the implementation will not run the compiler to obtain the function value. Some implementations do not even have interpreters; whenever it is called for, they run the compiler in a fast compilation-speed mode. > Some heuristic says whether it is more efficient to > invest the time to compile f, making execution more > efficient, or whether executing the interpreted code > is better. > > I should mention, that this isn't even the full truth: > actually, before the first call to f, f is defined as > > '(lambda (x) (comp f (generate rewrite-rules-of-f)) (f x)) You need to be more careful about how you write code in emails, so we understand exactly what you mean. Are you sure you mean to quote this above expression? The basic rule is: write code exactly how it appears in your source, and write generated values exactly how Lisp prints them out. * '(a b c) (A B C) * '(lambda () t) (LAMBDA NIL T) * (lambda () t) #<FUNCTION ...> Big difference in the last two. -- ;; Matthew Danish -- user: mrd domain: cmu.edu ;; OpenPGP public key: C24B6010 on keyring.debian.org
