- object-evict X #!optional ALLOCATORprocedure
Copies the object X recursively into the memory pointed to by the foreign pointer object returned by ALLOCATOR. The freshly copied object is returned. ALLOCATOR should be a procedure of a single argument (the number of bytes to allocate), and defaults to allocate.
This facility allows moving arbitrary objects into static memory, but care should be taken when mutating evicted data: setting slots in evicted vector-like objects to non-evicted data is not allowed. It is possible to set characters/bytes in evicted strings or byte-vectors, though. It is advisable not to evict ports, because they might be mutated by certain file-operations. object-evict is able to handle circular and shared structures.
Evicted symbols are no longer unique: a fresh copy of the symbol is created, so
(define x 'foo) (define y (object-evict 'foo)) y ==> foo (eq? x y) ==> #f (define z (object-evict '(bar bar))) (eq? (car z) (cadr z)) ==> #t
This loss of uniqueness also implies that an evicted structure -- such as one created with define-record -- cannot be operated on with the existing predicate or accessors, as internally a symbol is used to denote the type:
(define-record point x y) (point? (make-point x y)) ; => #t (point? (object-evict (make-point x y))) ; => #f