[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is this a bug or am I just not understanding applying Wood?



>Bill: I think the definition of set-slot-value-in-both-worlds
>(repeated below) is buggy. I'm pretty sure the second WHEN should use
>slot-value, not p-slot-value. (P-slot-value does nothing if its arg is
>not a pptr).
>
>matt
>
>    (defun wood::set-slot-value-in-both-worlds (pheap instance slot-name value)
>      (let ((in-memory (wood::in-memory-p instance))
>	    (on-disk (wood::on-disk-p pheap instance)))
>	(when on-disk
>	  (setf (p-slot-value on-disk slot-name) value))
>	(when in-memory
>	  (setf (p-slot-value in-memory slot-name) value))) ;should be slot-value
>      value)

You're right, though this code should work since (setf p-slot-value)
simply calls (setf slot-value) if the instance is not a PPTR.

Well, that's what it was supposed to do, but (setf p-slot-value)
had a bug as well. Here's a patch:

------------------------------------------------------------------------

; setf-p-slot-value-patch.lisp
;
; (setf (p-slot-value instance slot) value)
; now calls (setf slot-value) when instance is not a PPTR.

(in-package :wood)

(let ((*warn-if-redefine* nil))

(defun (setf p-slot-value) (value p slot-name)
  (if (pptr-p p)
    (let* ((pheap (pptr-pheap p))
           (disk-cache (pheap-disk-cache pheap))
           (pointer (pptr-pointer p)))
      (multiple-value-bind (slots index)
                           (dc-%slot-vector-and-index disk-cache pointer slot-name)
        (unless slots
          (dc-slot-missing disk-cache pointer slot-name '(setf p-slot-value)))
        (multiple-value-bind (v imm?) (%p-store pheap value)
          (setf (dc-%svref disk-cache slots index imm?) v)
          (if imm?
            v
            (pptr pheap v)))))
    (setf (slot-value p slot-name) value)))

)