[slime-devel] MOP access
Helmut Eller
e9626484 at stud3.tuwien.ac.at
Tue Aug 31 20:23:24 UTC 2004
Rui Patrocínio <rui.patrocinio at netvisao.pt> writes:
> Hi,
>
> Is there any access to MOP-like functionality in swank? I've not found
> it so I create a simple interface, similar to the xref one.
No, there is no such thing.
> swank.lisp:
> ;;; MOP
> (defslimefun mop (type symbol-name)
> (let ((symbol (parse-symbol-or-lose symbol-name *buffer-package*)))
> (ecase type
> (:subclasses (class-direct-subclasses symbol))
> (:superclasses (class-direct-superclasses symbol)))))
>
> Maybe 'mop' isn't the best name.
It is a least short :-) If you add a docstrings, things should be fine.
> swank-cmucl.lisp:
> ;;; CLOS MOP
> (defimplementation class-direct-subclasses (class-name)
> (handler-bind ((simple-error (lambda (c)
> (declare (ignore c))
> (return-from class-direct-subclasses
> nil))))
> (let* ((class (find-class class-name))
> (subclasses (pcl:class-direct-subclasses class)))
> (mapcar #'(lambda (x)
> (symbol-name (pcl:class-name x)))
> subclasses))))
[...]
> The handler is to catch the errors of find-class with a class that
> doesn't exist. Maybe there's a better behaviour in that situation.
It might be simpler to export the MOP functions directly from the
swank-backend, e.g., just adding
(export 'pcl:class-direct-subclasses)
in swank-cmucl and the analog in the other backends. This could save
us the work for inventing a new interface and the AMOP specification
is probably not that bad. Whether the implementations agree with AMOP
specification is, of course, a different question.
We can probably also save some code duplication if we move the error
handling and class->name translation to swank.lisp.
Helmut.
More information about the slime-devel
mailing list