Welcome to the CHICKEN Scheme pasting service

ephemeron test added by sytse on Fri Mar 16 13:10:13 2018

($deftest srfi-124-ephemerons
  ($import! emacs-global garbage-collect)
  ($letrec ((fn ((k v)
                  ($let ((e (make-ephemeron k (cons k v))))
                    (garbage-collect)
                    (reference-barrier k)
                    e))))
    ($let* ((v "value")
            (e ($let ((e (fn (list 42) v)))
                 ($should (not? (ephemeron-broken? e)))
                 ($should (equal? (cons (list 42) "value") (ephemeron-value e)))
                 ;; This triggers the bad behavior of the interpreter:
                 ((constant #inert) (ephemeron-key e))
                 (garbage-collect)
                 ;; ($should (ephemeron-broken? e))
                 (display "Should be (#t #f #f): ")
                 ;; Unfortunately, this prints (#f (42) ((42) . "value"))
                 (writenl (list (ephemeron-broken? e)
                                (ephemeron-key e)
                                (ephemeron-value e)))
                 e)))
      ;; Here the return value of the first ephemeron-key call has
      ;; disappeared from the stack:
      (garbage-collect)
      ($should (ephemeron-broken? e))
      ($should (eq? #f (ephemeron-key e)))
      ($should (eq? #f (ephemeron-value e))))))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Which procedure can be used to check whether its argument is a symbol?
Visually impaired? Let me spell it for you (wav file) download WAV