Closures for local functions can be allocated on the stack if the
local function is declared dynamic-extent, and the closure
appears as an argument in the call of a named function. In the
example:
(defun foo (x)
(flet ((bar () x))
(declare (dynamic-extent #'bar))
(baz #'bar)))
the closure passed to function baz is allocated on the stack.
Likewise in the example:
(defun foo (x)
(flet ((bar () x))
(baz #'bar)
(locally (declare (dynamic-extent #'bar))
(baz #'bar))))
Stack-allocation of closures can also automatically take place when
calling certain known CL functions taking function arguments, for
example some or find-if.