[elephant-devel] Transient slots in non-persistent objects
Ben
ben at medianstrip.net
Wed Oct 20 18:07:58 UTC 2004
that's an intriguing option. the MOP way to do this (not that it's
particularly better) would be to subclass the standard slot definition
class, and have the persistent-slot-p method specialize on class, not
name. in fact we already do this for slots in persistent classes, so
there is an opportunity for integration here. however getting
defclass to use non-standard slot definition objects might be just as
much work as using persistent classes.
in any case, i'll take a look at merging your patch soon and let you
know.
take care, B
On Wed, 20 Oct 2004, Peter Bengtson wrote:
> Would this work?
>
> ;;;
> ;;; Patch Elephant to allow specification of transient slots for
> non-persistent objects
> ;;;
>
> (in-package :elephant)
>
> (defun slots-and-values (o)
> (declare (optimize (speed 3) (safety 0)))
> (let ((class (class-of o)))
> (loop for sd in (compute-slots class)
> for slot-name = (slot-definition-name sd)
> with ret = ()
> do
> (when (and (persistent-slot-p class slot-name)
> (slot-boundp o slot-name)
> (eq :instance (slot-definition-allocation sd)))
> (push (slot-value o slot-name) ret)
> (push slot-name ret))
> finally (return ret))))
>
>
> (defmethod persistent-slot-p ((class t) (slot-name t))
> t)
>
>
> (export 'persistent-slot-p)
>
>
> ;;;
> ;;; This would be used in the application in the following manner, assuming
> there is
> ;;; a class called CLIENT with a slot called CLIENT-SOCKET containing
> transient data:
>
> (in-package :cl-user)
>
> (defmethod persistent-slot-p ((class client) (slot-name (eql
> 'client-socket)))
> nil)
>
>
> / Peter
>
More information about the elephant-devel
mailing list