With the latest Git revision on SBCL 1.0.51, when trying to migrate
objects that have a derived slot, elephant tries to call setf
slot-value-using-class on the derived slot, resulting in an error :
"Cannot write computed (derived) slot... for read/index retrieval
only".

It seems to me that copy-persistent-slots shouldn't try to write
derived slots, as the work will be done when (setf
slot-value-using-class) is called on the slots the derived function
depends on.

So I tried to patch the code for that (see attached patch). This seems
to do the trick in that the migration works.

I stumble upon another problem though : the derived slots are unbound
after migration. Apparently, update-derived-slots is called when
copying slot values, but derived-slots-trigger seems to always return
nil... I don't get why.

Here's my test case if anyone is interested (notice that I need to
require bordeaux-threads manually, which is probably a small
dependency bug ?). The first describe shows c=3, as expected, while
the second describe shows c unbound.

(require 'elephant)
(require 'bordeaux-threads)
(use-package 'elephant)

(defvar *store1* (open-store '(:BDB "store1")))
(defvar *store2* (open-store '(:BDB "store2")))

(defpclass test ()
  ((a :type integer :accessor a :initarg :a)
   (b :type integer :accessor b :initarg :b)
   (c :derived-fn (λ (obj) (values (+ (a obj) (b obj)) t)))))

(let ((*store-controller* *store1*))
  (describe (make-instance 'test :a 1 :b 2)))
(migrate *store2* *store1*)
(close-store *store1*)
(describe (first (get-instances-by-class 'test)))

Attachment: patch_migrate_derived
Description: Binary data

_______________________________________________
elephant-devel site list
elephant-devel@common-lisp.net
http://common-lisp.net/mailman/listinfo/elephant-devel

Reply via email to