I'd like to add a procedure called REFERENCE-BARRIER to the system.
(REFERENCE-BARRIER <x>) has the consequence that whatever the value of
<x>, the garbage collector must not reclaim the storage of anything
strongly referenced by <x> until after the call to REFERENCE-BARRIER.

For example, the following is always true:

(let* ((p (cons 0 0))
       (wp (weak-cons p 0)))
  (gc-flip)
  (let ((result (weak-pair/car? wp)))
    (reference-barrier p)
    result))

By contrast, this may yield true or false:

(let* ((p (cons 0 0))
       (wp (weak-cons p 0)))
  (gc-flip)
  (weak-pair/car? wp))

Interpreted, it usually yields true; compiled, false.

I have been using IDENTITY-PROCEDURE for REFERENCE-BARRIER, because it
usually results in a general procedure call, with the desired
consequences.  However, some day IDENTITY-PROCEDURE may be integrated,
losing that property.  Even if IDENTITY-PROCEDURE never lost that
property, it would be nice if REFERENCE-BARRIER could be open-coded
(and eliminated altogether if the compiler can prove it unnecessary
within a block of code).  For now, REFERENCE-BARRIER can just be an
alias to IDENTITY-PROCEDURE.

Comments?

_______________________________________________
MIT-Scheme-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/mit-scheme-devel

Reply via email to