Define a macro that eliminates this repetitive pattern:
(define-hook (:build finalize-clos -10000000000) () (labels ((finalize-function (fun) (when (and (typep fun 'generic-function) (not (sb-pcl::special-case-for-compute-discriminating-function-p fun))) (multiple-value-bind (dfun cache info) (sb-pcl::make-final-dfun-internal fun) (sb-pcl::update-dfun fun dfun cache info)))) (finalize-class (class) (unless (sb-mop:class-finalized-p class) (sb-mop:finalize-inheritance class) (dolist (class (sb-mop:class-direct-subclasses class)) (finalize-class class))) (when (typep class 'standard-class) (sb-mop:compute-slots class)))) (do-all-symbols (symbol) (when (find-class symbol NIL) (handler-case (finalize-class (find-class symbol)) (error () (status 3 "Failed to finalize class ~a" symbol))))) (do-all-symbols (symbol) (when (fboundp symbol) (handler-case (finalize-function (fdefinition symbol)) (error () (status 3 "Failed to finalize function ~a" symbol)))) (when (fboundp `(setf ,symbol)) (handler-case (finalize-function (fdefinition `(setf ,symbol))) (error () (status 3 "Failed to finalize function ~a" `(setf ,symbol)))))) (loop for v being the hash-values of sb-pcl::*all-ctors* do (sb-pcl::install-initial-constructor v) (ignore-errors (ecase (sb-pcl::ctor-type v) (sb-pcl::ctor (sb-pcl::install-optimized-constructor v)) (sb-pcl::allocator (sb-pcl::install-optimized-allocator v)))))))

Issue: Macro call that should be transformed by define-hook

Macro definition:
(defmacro define-hook ((type name &optional (priority 0)) args &body body)
  (ecase type (:pre-load) (:load) (:build) (:deploy) (:boot) (:quit))
  (check-type name symbol)
  `(let ((,name (or (hook ,type ',name)
                    (make-instance 'hook :name ',name :type ,type))))
     (setf (hook-priority ,name) ,priority)
     (setf (hook-function ,name) (flet ((,name (&key ,@args &allow-other-keys)
                                          ,@body))
                                   #',name))
     (setf (hook ,type ',name) ,name)
     (setf (docstring ,name) ,(if (stringp (car body)) (car body)))
     ',name))

Macroexpansion:
(let ((finalize-clos (or (hook :build (quote finalize-clos)) (make-instance (quote hook) :name (quote finalize-clos) :type :build)))) (setf (hook-priority finalize-clos) -10000000000) (setf (hook-function finalize-clos) (flet ((finalize-clos (&key &allow-other-keys) (labels ((finalize-function (fun) (when (and (typep fun (quote generic-function)) (not (sb-pcl::special-case-for-compute-discriminating-function-p fun))) (multiple-value-bind (dfun cache info) (sb-pcl::make-final-dfun-internal fun) (sb-pcl::update-dfun fun dfun cache info)))) (finalize-class (class) (unless (sb-mop:class-finalized-p class) (sb-mop:finalize-inheritance class) (dolist (class (sb-mop:class-direct-subclasses class)) (finalize-class class))) (when (typep class (quote standard-class)) (sb-mop:compute-slots class)))) (do-all-symbols (symbol) (when (find-class symbol nil) (handler-case (finalize-class (find-class symbol)) (error nil (status 3 "Failed to finalize class ~a" symbol))))) (do-all-symbols (symbol) (when (fboundp symbol) (handler-case (finalize-function (fdefinition symbol)) (error nil (status 3 "Failed to finalize function ~a" symbol)))) (when (fboundp (sb-int:quasiquote (setf #S(sb-impl::comma :expr symbol :kind 0)))) (handler-case (finalize-function (fdefinition (sb-int:quasiquote (setf #S(sb-impl::comma :expr symbol :kind 0))))) (error nil (status 3 "Failed to finalize function ~a" (sb-int:quasiquote (setf #S(sb-impl::comma :expr symbol :kind 0)))))))) (loop for v being the hash-values of sb-pcl::*all-ctors* do (sb-pcl::install-initial-constructor v) (ignore-errors (ecase (sb-pcl::ctor-type v) (sb-pcl::ctor (sb-pcl::install-optimized-constructor v)) (sb-pcl::allocator (sb-pcl::install-optimized-allocator v)))))))) (function finalize-clos))) (setf (hook :build (quote finalize-clos)) finalize-clos) (setf (docstring finalize-clos) nil) (quote finalize-clos))