2006-12-19 12:15:36 -05:00
|
|
|
|
2006-12-24 04:20:16 -05:00
|
|
|
;;; The procedure make-guardian is coped en verbatim
|
|
|
|
;;; from Dybvig et al. Guardians paper.
|
|
|
|
|
2007-04-30 00:33:22 -04:00
|
|
|
(library (ikarus guardians)
|
2007-05-05 03:03:50 -04:00
|
|
|
(export make-guardian)
|
|
|
|
(import (except (ikarus) make-guardian))
|
|
|
|
(define make-guardian
|
2006-12-19 12:15:36 -05:00
|
|
|
(lambda ()
|
|
|
|
(let ([tc
|
|
|
|
(let ([x (cons #f #f)])
|
|
|
|
(cons x x))])
|
|
|
|
(case-lambda
|
|
|
|
[()
|
|
|
|
(and (not (eq? (car tc) (cdr tc)))
|
|
|
|
(let ([x (car tc)])
|
|
|
|
(let ([y (car x)])
|
|
|
|
(set-car! tc (cdr x))
|
|
|
|
(set-car! x #f)
|
|
|
|
(set-cdr! x #f)
|
|
|
|
y)))]
|
|
|
|
[(obj)
|
|
|
|
(foreign-call "ikrt_register_guardian" tc obj)
|
2007-04-30 00:33:22 -04:00
|
|
|
(void)])))))
|