X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/f64eb323a5798e155cc494043f5f750abf50a482..f458e64e36509fa8c204f1dbcafff1d3dc059619:/src/class-make-proto.lisp diff --git a/src/class-make-proto.lisp b/src/class-make-proto.lisp index d075304..2e1fe7c 100644 --- a/src/class-make-proto.lisp +++ b/src/class-make-proto.lisp @@ -28,6 +28,14 @@ ;;;-------------------------------------------------------------------------- ;;; Classes. +(export 'guess-metaclass) +(defgeneric guess-metaclass (class) + (:documentation + "Determine a suitable metaclass for the CLASS. + + The default behaviour is to choose the most specific metaclass of any of + the direct superclasses of CLASS, or to signal an error if that failed.")) + (export 'make-sod-class) (defun make-sod-class (name superclasses pset &optional location) "Construct and return a new SOD class with the given NAME and SUPERCLASSES. @@ -46,12 +54,13 @@ (with-default-error-location (location) (let* ((pset (property-set pset)) (best-class (or (get-property pset :lisp-metaclass :symbol nil) - (if superclasses - (maximum (mapcar #'class-of superclasses) - #'subtypep - (format nil "Lisp metaclass for ~A" - name)) - 'sod-class))) + (select-minimal-class-property + superclasses #'class-of #'subtypep 'sod-class + "Lisp metaclass" + :present (lambda (class) + (format nil "`~S'" + (class-name class))) + :allow-empty t))) (class (make-instance best-class :name name :superclasses superclasses