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

Efficiency of local fns and closures



Consider:

(defun foo (x y)
  (labels ((bar (z)
	    (some-function y z)))		;free reference to y
    (bar (some-other-function x))))

I have a two-part question regarding efficiency:

a) In general, are local functions any slower w.r.t. a global fn definition
   that may do the same thing?  I.e. is there any reason to expect BAR
   to run faster if it were defined globally?
b) Does the presence of the lexically-apparent free reference to 'y'
   impact how a) is answered?
   If free ocurrence of 'y' slows down BAR, can that be avoided by
   passing 'y' to BAR as a second argument?

Separate question (but related in some sense):
c) I have read that closures cannot be compiled.  True? False?
   Implementation dependent?  (For extra credit: If true, why?)

-Kurt Godden
 godden@gmr.com