From: Ik Su Yoo
Subject: CL and lexical closures
Date: 
Message-ID: <638@laic.UUCP>
It seems to me like whenever one uses #'(lambda ...), there is an
overhead because the form must remember its lexical environment.
Although I find these kinds of forms very useful, I still have
questions about their cost:

  1. How much cost is there for using lexical closures?

  2. Is lexical closure always created when using #'(lambda ...), or
     only when there is a free variable access within the form? If the
     former, does it save all bindings?

  3. [related to 2] Which of the following is more efficient?

       (defun store-fn (slot-name)
	 (setf (get slot-name 'lookup-fn)
	       #'(lambda (object)
		   (foo object slot-name))))

       (defun store-fn (slot-name)
	 (setf (get slot-name 'lookup-fn)
	       (eval `(compile nil
			       #'(lambda (object)
				   (foo object ',slot-name))))))

Thanks in advance for any insights.
From: John Nagle
Subject: Re: CL and lexical closures
Date: 
Message-ID: <12910@well.UUCP>
In article <···@laic.UUCP> ··@.UUCP () writes:
-  3. [related to 2] Which of the following is more efficient?
-
-       (defun store-fn (slot-name)
-	 (setf (get slot-name 'lookup-fn)
-	       #'(lambda (object)
-		   (foo object slot-name))))
-
-       (defun store-fn (slot-name)
-	 (setf (get slot-name 'lookup-fn)
-	       (eval `(compile nil
-			       #'(lambda (object)
-				   (foo object ',slot-name))))))
-
     Since the second will invoke the compiler at run-time, it is highly
undesirable in a production program.  With KCL, this will result in a
delay of a second or more as the compiler is loaded, and this will occur
every time the function is invoked.

					John Nagle