Plaster
New
List
Login
common-lisp
default
anonymous
2020.05.16 20:04:15
(defclass my-generic-function (standard-generic-function) () (:metaclass closer-mop:funcallable-standard-class)) ;; Works fine (defgeneric a-function (x) (:generic-function-class my-generic-function)) (defgeneric another-function (x)) ;; Fails due to definition above. (defgeneric another-function (x) (:generic-function-class my-generic-function)) => Cannot CHANGE-CLASS objects into GENERIC-FUNCTION metaobjects. [Condition of type SB-PCL::METAOBJECT-INITIALIZATION-VIOLATION] See also: The Art of the Metaobject Protocol, GENERIC-FUNCTION [:initialization]
Raw
Annotate
Repaste
Edit
Annotations
common-lisp
default
anonymous
2020.05.16 20:39:21
;; Error checking still required. (defgeneric migrate-methods (source-generic-function target-generic-function) (:method (source target) (let ((methods (closer-mop:generic-function-methods source))) (dolist (m methods) (remove-method source m) (add-method target m))))) (defgeneric replace-generic-function-using-class (generic-function class) (:method ((name symbol) (class symbol)) (let ((gf (fdefinition name))) (fmakunbound name) (migrate-methods gf (ensure-generic-function name :generic-function-class class :lambda-list (closer-mop:generic-function-lambda-list gf) :name name)))))
Raw
Repaste
Edit