[Openmcl-devel] edit-definition for slot accessors

Gary Byers gb at clozure.com
Fri Mar 23 13:13:06 UTC 2007


Thanks.  The only thing that I can think of to suggest is that it
might be slightly better to use an indicator of the form (ACCESSOR
. <class-name>) for an accessor defined on a slot in the class whose
name is <class-name>.

In general, what we'd like M-. to be able to do to find the "source
location" of an automatically defined accessor is something like:

- search for a DEFCLASS form which defines the named class
- within that DEFCLASS, search for a slot definition with the
   indicated :accessor or :reader option (or maybe :writer).

If we don't tell M-. what class, it could look at all DEFCLASS forms
until it found one that defined the accessor.

A lot of M-. implementations will probably fall back to just
doing a simple string search if they can't find a reasonable-looking
defining form (so if FOO is recorded as being defined in "foo.lisp"
with an indicator of (ACCESOR . some-class) and that indicator doesn't
help, M-. will just search for the string "foo".  (That's how MCL
handled slot accessors, incidentally, and it "works" some of the time.)
Moral: some source info is better than none ...


On Fri, 23 Mar 2007, Takehiko Abe wrote:

> Slot accessors does not seem to be recorded into ccl::%source-files% .
> meta-dot does not work for them.
>
> ensure-class-for-defclass has this comments:
>
> ;; Maybe record source-file information for accessors as well
> ;; We should probably record them as "accessors of the class", since
> ;; there won't be any other explicit defining form associated with
> ;; them.
>
> Here's my take:
>
> (let ((*warn-if-redefine* nil)
>      (*warn-if-redefine-kernel* nil))
>
> (defun ensure-class-for-defclass (name &rest keys &key &allow-other-keys)
>  (record-source-file name 'class)
>  ;; Maybe record source-file information for accessors as well
>  ;; We should probably record them as "accessors of the class", since
>  ;; there won't be any other explicit defining form associated with
>  ;; them.
>  ;; ***
>  (let ((slots (getf keys :direct-slots)))
>    (dolist (slot slots)
>      (dolist (reader (getf slot :readers))
>        (record-source-file reader 'accessor))
>      (dolist (writer (getf slot :writers))
>        (unless (consp writer)
>          (record-source-file writer 'accessor)))))
>
>  (let* ((existing-class (find-class name nil)))
>    (when (and *defclass-redefines-improperly-named-classes-pedantically*
>               existing-class
>              (not (eq (class-name existing-class) name)))
>      ;; Class isn't properly named; act like it didn't exist
>      (setq existing-class nil))
>    (apply #'ensure-class-using-class existing-class name keys)))
> )
>
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>



More information about the Openmcl-devel mailing list