From: Daniel Mahler
Subject: implementing class (static) methods in MOP
Date: 
Message-ID: <328AD219.659C@ozemail.com.au>
I want to extend CLOS method dispatch with class (aka static) functions.
This should be done naturally by defining a new specialiser subclass.
In particular the following should work:


(defclass A (standard-class)
	....)

(defclass meta-B (standard-class)
	...)

(defclass B (A)
	...
	(:metaclass meta-B))

(defgeneric f (x) ...)

(defmethod f ((x class)) ...) ;; method 1

(defmethod f ((x meta-B)) ...) ;; method 2

(defmethod f ((x (static class))) ...) ;; method 3

(defmethod f ((x (static A))) ...) ;; method 4

(defmethod f ((x (eql (find-class 'B))) ...) ;; method 5

(compute-applicable-methods #'f (list (find-class 'B)))

This should return all 5 of the above methods in reverse order.
The only extension to the MOP should be in specifying that
static specialisers have higher precedence than class specialisers
and lower precedence than eql specialisers
and that static-specialisers are ordered by standard class precedence.
Standard parts of the MOP should take care of the rest.
The problem is than precedence comparison of specialisers
does not appear to be documented part of the MOP.
(Very little seems documented about specialisers.)
This means that I actually have to modify compute-applicable-methods,
which seems to entail introducing a new subclass of generic-function.
It then seems difficult to reuse the built in CLOS method ordering.
Also static specialisers cannot be used in
in new methods of existing generics.

Have I missed something?
Is there a cleaner way to do this?
Has someone done it already?
Is there a semi-official interface to specialiser ordering?
It appears that compute-applicable-methods
must use such a mechanism.

thanks

Daniel Mahler
ยทยทยทยท@ozemail.com.au
Software Engineer
RHO Transformation Technologies