Welcome to the CHICKEN Scheme pasting service

set-finalizer! - How does it work? added by andyjpb on Wed Feb 27 01:38:19 2013


(use srfi-18)

(define p (make-parameter #f))

(define (finaliser x) (printf "GC of ~A.\n" x))

(define (attach-finaliser)
 (printf "Starting ~A.\n" (current-thread))
 (let ((x '(a b c)))
  (set-finalizer! (p) finaliser)
  (set-finalizer! x finaliser)
  (thread-sleep! 3)
 )
 (printf "Ending ~A.\n" (current-thread)))

(thread-start! (make-thread attach-finaliser))

(thread-sleep! 10)

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
What's the procedure that returns the cdr of a cdr?
Visually impaired? Let me spell it for you (wav file) download WAV