summaryrefslogtreecommitdiff
path: root/testsuite/t-call-cc.scm
blob: 05e4de98c0f0a7667783bc131867bad73da31a8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
(let ((set-counter2 #f))
  (define (get-counter2)
    (call/cc
     (lambda (k)
       (set! set-counter2 k)
       1)))
  (define (loop counter1)
    (let ((counter2 (get-counter2)))
      (set! counter1 (1+ counter1))
      (cond ((not (= counter1 counter2))
             (error "bad call/cc behaviour" counter1 counter2))
            ((> counter1 10)
             #t)
            (else
             (set-counter2 (1+ counter2))))))
  (loop 0))