Hi,

 I posted on comp.lang.lisp a question about
define-method-combination:

<snip>
;Order methods by positive integer qualifiers
;:around methods are disallowed to keep the example
small
(define-method-combination example-method-combination
()
  ((methods positive-integer-qualifier-p))
  `(progn ,@(mapcar #'(lambda (method)
                        `(call-method ,method))
               (stable-sort methods #'<
                   :key  #'(lambda (method)
                             (first (method-qualifiers
method)))))))

(defun positive-integer-qualifier-p
(method-qualifiers)
  (and (= (length method-qualifiers) 1)
       (typep (first method-qualifiers) '(integer 0
*))))

(defgeneric foo (bar baz) (:method-combination
example-method-combination))

(defmethod foo 1 (bar baz)
  (format T "foo one ~A ~A~%" bar baz))


(foo 'a 'b) => prints "foo one a b"

(defmethod foo 2 (bar baz)
  (format T "foo two ~A ~A~%" bar baz))

(foo 'a 'b) => errors with "More than one method of
type METHODS with the same specializers."

I'd expect it to first print "foo one a b" then "foo
two a b", but again, maybe I'm missing something. 
</snip>

and James Anderson kindly replied, saying that it's
probably a case where there's more than one
interpretation of the spec:

<snip> James Anderson wrote:
the error which you observe is the consequence of one
possible interpretation
of the spec. the error message is a bit misleading. i
suggest that it is not
the only interpretation and is neither necessary nor
useful. as an additional
data point, mcl does what i believe you would have
expected. the issue is not
explained entirely by 7.6.*, as it depends on the term
"role", which is
described in the definition for
define-method-combination. 

...


the definition does however also say

"It is also possible to bypass the method group
specifier mechanism and do
everything in the body forms."

in its description of the interpretation for the *
pattern.

there is some sense in which this contradicts the
uniqueness rules for
matching, but the only useful interpretation is that
it is a special case, in
which the uniqueness constraint does not apply. in any
other interpretation,
where one identifies * with a single "role", the
qualifiers no longer have any
significance and the provision, that the method
combination can "do everything
in the body forms" is vacuous. i would not think that
this was the intent.
</snip>

If I found the time and actually figured out a patch
for pcl such that the above example works as I think
it should, is that something that the cmucl
maintainers would be interested in accepting?

It would basically mean not erroring out at the point
the methods are assigned to a group.

I wanted to grab some comments before I dug in.

Thanks,
Wendall


__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

Reply via email to