2

这个警告是什么意思?我有一个我在下面使用的示例,带有此警告。我在某处做错了吗?

(defvar B_00 0)
(defvar B_000 0)
(defvar w_000 0)
(defvar w_00 0)
(defconstant white 0)

(defclass board ()
 ((blocker    :accessor blocker    :initarg :blocker    :initform  0)
  (friends    :accessor friends    :initarg :friends    :initform (make-array '(2)))
  (kings      :accessor kings      :initarg :kings      :initform (make-array '(2)))
  (boards     :accessor boards     :initarg :boards     :initform (make-array '(2 7) :initial-element 0))
  (enpassant  :accessor enpassant  :initarg :enpassant  :initform -1)
  (color      :accessor color      :initarg :color      :initform  WHITE)
  (castling   :accessor castling   :initarg :castling   :initform  (logior B_000 B_00 W_000 W_00))
  (hasCastled :accessor hasCastled :initarg :hasCastled :initform  (make-array '(2) :initial-element nil))
  (fifty      :accessor fifty      :initarg :fifty      :initform 0)
  (checked    :accessor checked    :initarg :checked    :initform nil)
  (opchecked  :accessor opchecked  :initarg :opchecked  :initform nil)
  (arBoard    :accessor arBoard    :initarg :arBoard    :initform (make-array '(64))) 
  (hash       :accessor hash       :initarg :hash       :initform 0)
  (pawnhash   :accessor pawnhash   :initarg :pawnhash   :initform 0)
  (history    :accessor history    :initarg :history    :initform '())))

(defmethod ischecked ((b board)) b)
4

1 回答 1

6

在定义实现它的任何方法之前,您应该使用DEFGENERIC定义一个泛型函数。没有匹配泛型函数定义的方法定义将自动(即隐式)创建泛型函数。但是,如果您自己定义了一个通用函数,即使您不需要任何特定的功能defgeneric(尽管接口文档是个好主意),如果您在任何方法定义中拼错名称,您都会收到警告。它还清楚地说明了如果参数被更改并且在方法之间变得不匹配,它们应该是什么。

于 2012-08-29T17:47:23.033 回答