On 5/23/07, Dan Muresan <[EMAIL PROTECTED]> wrote:
Evicted objects do not work with srfi-9 records for some reason:
(define-record-type :pare
(kons x y)
pare?
(x kar set-kar!)
(y kdr))
(kar (object-evict (kons 1 2)))
Error: bad argument type - not a structure of the required type
The zeroth "slot" of the record contains the symbol representing its
type. When you evict the record, you also evict the symbol. The
interned and uninterned symbols are not equal, hence the type-check
failure when it is inspected.
(equal? :pare (object-evict :pare)) => #f
You could set the slot-value back to the non-evicted, interned symbol:
(let ((p (object-evict (kons 1 2))))
(##sys#setslot p 0 :pare)
(kar p))
=> 1
or a more general way:
(define (reintern-record-symbol! rec)
(##sys#setslot rec 0
(string->symbol (->string
(##sys#slot rec 0)))))
(let ((p (object-evict (kons 1 2))))
(reintern-record-symbol! p)
(kar p))
I'm not sure what the implications of this are, though. Maybe your
process will blow up after GC. :-)
Graham
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users