contin.scm 630 B

123456789101112131415161718192021
  1. ; Copyright (c) 1993-2007 by Richard Kelsey and Jonathan Rees. See file COPYING.
  2. ; Continuations implemented as vectors.
  3. (define *continuation-marker* (list '*continuation-marker*))
  4. (define (make-continuation len init)
  5. (let ((c (make-vector (+ len 1) init)))
  6. (vector-set! c 0 *continuation-marker*)
  7. c))
  8. (define (continuation? obj)
  9. (and (vector? obj)
  10. (> (vector-length obj) 0)
  11. (eq? (vector-ref obj 0) *continuation-marker*)))
  12. (define (continuation-length c) (- (vector-length c) 1))
  13. (define (continuation-ref c i) (vector-ref c (+ i 1)))
  14. (define (continuation-set! c i x) (vector-set! c (+ i 1) x))