4
什麼是在包A中定義泛型並在CLOS中爲包B中的泛型提供一種方法的正確方法?Common Lisp中的跨包defmeneric/defmethod?
預先感謝您!
例子:
(defpackage :common (:use :cl))
(in-package :common)
(defgeneric compare (a b))
(defmethod compare ((a number) (b number))
(cond ((< a b) -1)
((= a b) 0)
(T 1)))
(defpackage :a (:use :cl))
(in-package :a)
(defclass foo (a b))
(defmethod compare ((x foo) (y foo)) ...)
; SBCL isn't able to access this method via the common package
非常感謝!正是我所期望的。 – Damg 2010-01-28 20:30:07