9.7.2 Constructing a Function as Part of Running an Application

You can supply an alternate top level (which initializes some things and then calls the regular top level) to construct a function as part of running the application. Note that when you use this technique, you can close the function over other pieces of the Lisp state that might not exist until application runtime.

 different-prompts ()
 ((prompt-state ...) ...) 
 (:top-level (different-prompts-top-level)) ...)


(defmethod different-prompts-top-level
  ((frame different-prompts) &rest options)
  (flet ((prompt (stream frame)
                 (with-slots (prompt-state) frame 
                              #'clim:default-frame-top-level frame
                              :prompt #'prompt options)))

CommonLisp Interface Manager 2.0 User's Guide - 30 Jul 2004