[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with method precedence



The following bit of code demonstrates what I think is a bug with
MCL's handling of method precedence. (I'm using mcl2.0b1p2.).
Following are the results of evaluating the code (with my comments)
and the code itself.

matt


Welcome to Macintosh Common Lisp Version 2.0b1p2!
? 
#<STANDARD-METHOD FOO (T T T T)>                              ;general method
#<STANDARD-METHOD FOO ((EQL :DRAG) (EQL 0) T (EQL ACCESSOR))> ;1st specialization
(#<STANDARD-METHOD FOO ((EQL :DRAG) (EQL 0) T (EQL ACCESSOR))> #<STANDARD-METHOD FOO (T T T T)>)

"usual one :drag 0 t 'accessor" 
"empty one" 
NIL                              ;correct behavior
#<STANDARD-METHOD FOO ((EQL :DRAG) (EQL 0) (EQL CLASS-NAME) WINDOW)> ;2nd specialization
(#<STANDARD-METHOD FOO ((EQL :DRAG) (EQL 0) T (EQL ACCESSOR))> #<STANDARD-METHOD FOO (T T T T)>)

"empty one" 
NIL
?                               ;wrong behavior (usual one isn't called)

======================= Demo code follows =======================
(defmethod foo ((gesture-type t)
                (modifiers-integer t)
                (arg1 t)
                (arg2 t))
  (print "empty one")
  ())

(defmethod foo ((gesture-type (eql :drag))
                (modifiers-integer (eql 0))
                (arg1 t)
                (arg2 (eql 'accessor)))
  (print "usual one :drag 0 t 'accessor")
  (call-next-method))

(compute-applicable-methods #'foo '(:drag 0 t accessor))
(foo :drag 0 t 'accessor)


(defmethod foo ((gesture-type (eql :drag))
                (modifiers-integer (eql 0))
                (arg1 (eql 'class-name))
                (arg2 window))
  (print "usual one :drag 0 'class-name window")
  (call-next-method))

(compute-applicable-methods #'foo '(:drag 0 t accessor))
(foo :drag 0 t 'accessor)
======================= End Demo code =======================