Slime's default inspector won't show slot values for metaclasses that override the default storage locations for objects slots (i.e. where the default slot-boundp returns nil). The elephant interface to Berkeley-DB is one such system. The
(defmethod inspect-for-emacs ((o standard-object) inspector) (declare (ignore inspector)) (values "An object." `("Class: " (:value ,(class-of o)) (:newline) "Slots:" (:newline) ,@(loop for slot in (swank-mop:class-slots (class-of o)) for slot-def = (find-effective-slot o slot) for slot-name = (swank-mop:slot-definition-name slot-def) collect `(:value ,slot-def ,(string slot-name)) collect " = " collect (if (swank-mop:slot-boundp-using-class (class-of o) o slot) `(:value ,(swank-mop:slot-value-using-class (class-of o) o slot-def)) "#<unbound>") collect '(:newline)))))
If you add the two calls to slot-boundp-using-class and slot-value-using-class as shown above you get the expected proper behavior for lisps that don't call the -using-class mop functions from the slot-value and slot-boundp functions. (I ran into this on Allegro 7.0 under Mac OS X).
The other change is to add these two functions to the swank-mop package exports.
It's a minor enough change I figured someone who checks in regularly can update this and provide some judgement on whether there are likely to be any problems.
Regards, Ian
* Ian Eslick [2006-01-24 03:39+0100] writes:
It's a minor enough change I figured someone who checks in regularly can update this and provide some judgement on whether there are likely to be any problems.
I committed that change and added the *-using-class functions to swank-mop. It seems to work for CMUCL, SBCL, and CLISP. For the rest, well, it may just work, or we will receive bug reports, or it doesn't matter enough so that nobody sends a bug report.
Helmut.
On Mon, 30 Jan 2006 21:12:11 +0100, Helmut Eller heller@common-lisp.net said:
Delivered-To: slime-devel@common-lisp.net
- Ian Eslick [2006-01-24 03:39+0100] writes:
It's a minor enough change I figured someone who checks in regularly can update this and provide some judgement on whether there are likely to be any problems.
I committed that change and added the *-using-class functions to swank-mop. It seems to work for CMUCL, SBCL, and CLISP. For the rest, well, it may just work, or we will receive bug reports, or it doesn't matter enough so that nobody sends a bug report.
LispWorks's *-using-class methods work with the slot name, not the slot definition. I suppose we can finess that in the swank-mop layer.
BTW, what kind of object returns NIL from SLOT-BOUNDP but still has a slot value and how is a user supposed to access it?
__Martin
Some Lisp implementations do not call the generic function slot-boundp-using-class as part of executing the normal lisp slot-boundp for performance reasons.
The specific problem I ran into was inspecting objects in Elephant (a persistent DB) where the metaobject protocol does not allocate storage for slots but redirects (via metaclass override of slot-boundp-using-class and slot-value-using-class) queries to disk database lookups. In this case slot-boundp returned nil, but slot-boundp-using-slot was returning 't'.
An alternative approach (safer?) rather than modifying swank-mop and forcing always using the generic function, would be to write a swank-slot-boundp defun that is selectively implemented by specific backends with this problem. i.e.
#-allegro (defun swank-slot-boundp (object slot) (slot-boundp object slot))
#+allegro (defun swank-slot-boundp (object slot) (slot-boundp-using-class (class-of object) object (<lookup-slot-def> slot)))
Ian
Martin Simmons wrote:
On Mon, 30 Jan 2006 21:12:11 +0100, Helmut Eller heller@common-lisp.net said:
Delivered-To: slime-devel@common-lisp.net
- Ian Eslick [2006-01-24 03:39+0100] writes:
It's a minor enough change I figured someone who checks in regularly can update this and provide some judgement on whether there are likely to be any problems.
I committed that change and added the *-using-class functions to swank-mop. It seems to work for CMUCL, SBCL, and CLISP. For the rest, well, it may just work, or we will receive bug reports, or it doesn't matter enough so that nobody sends a bug report.
LispWorks's *-using-class methods work with the slot name, not the slot definition. I suppose we can finess that in the swank-mop layer.
BTW, what kind of object returns NIL from SLOT-BOUNDP but still has a slot value and how is a user supposed to access it?
__Martin
Helmut Eller <heller <at> common-lisp.net> writes:
I committed that change and added the *-using-class functions to swank-mop. It seems to work for CMUCL, SBCL, and CLISP. For the rest, well, it may just work, or we will receive bug reports, or it doesn't matter enough so that nobody sends a bug report.
(defclass test-object () ((id :accessor id :initform 1 :initarg :id))) #<STANDARD-CLASS TEST-OBJECT 21E75474>
CL-USER> (make-instance 'test-object) #<TEST-OBJECT 21EA314C>
Using Slime to Inspect 'test-object' returns...
The slot #<STANDARD-EFFECTIVE-SLOT-DEFINITION ID 22066634> is missing from #<TEST-OBJECT 220665C4> (of class #<STANDARD-CLASS TEST-OBJECT 22064D04>), when reading the value. [Condition of type CONDITIONS::SLOT-MISSING-ERROR]
Restarts: 0: [ABORT-REQUEST] Abort handling SLIME request. 1: [ABORT] Quit process.
Backtrace: 0: CONDITIONS::CONDITIONS-ERROR (:INVISIBLEP T CONDITIONS::SLOT-MISSING-ERROR (:NAME #<STANDARD-EFFECTIVE-SLOT-DEFINITION ID 22066634> :INSTANCE #<TEST-OBJECT 220665C4> :CLASS #<STANDARD-CLASS TEST-OBJECT 22064D04> :OPERATION SLOT-BOUNDP : NEW-VALUE NIL)) 1: #<function 20728922> NIL 2: CLOS::SLOT-BOUNDP-MISSING (#<record 1309 (ID) NIL #<STANDARD-CLASS TEST- OBJECT 22064D04>> #<TEST-OBJECT 220665C4> #<STANDARD-EFFECTIVE-SLOT-DEFINITION ID 22066634>) 3: (METHOD SWANK-BACKEND:INSPECT-FOR-EMACS (STANDARD-OBJECT T)) (#<TEST-OBJECT 220665C4> :DONT-KNOW) 4: SWANK::INSPECT-OBJECT (#<TEST-OBJECT 220665C4> &OPTIONAL #<SWANK-BACKEND:: LISPWORKS-INSPECTOR 206A213C>) 5: SWANK::CALL-WITH-BUFFER-SYNTAX (#<closure (SUBFUNCTION 1 SWANK:INIT- INSPECTOR) 206A1FA2>)
This is under Lispworks. I'm using the Jan, 30'th version of SLIME from CVS.
-Luke