scsh-0.5/alt/contin.scm

21 lines
629 B
Scheme
Raw Permalink Normal View History

1995-10-13 23:34:21 -04:00
; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING.
; Continuations implemented as vectors.
(define *continuation-marker* (list '*continuation-marker*))
(define (make-continuation len init)
(let ((c (make-vector (+ len 1) init)))
(vector-set! c 0 *continuation-marker*)
c))
(define (continuation? obj)
(and (vector? obj)
(> (vector-length obj) 0)
(eq? (vector-ref obj 0) *continuation-marker*)))
(define (continuation-length c) (- (vector-length c) 1))
(define (continuation-ref c i) (vector-ref c (+ i 1)))
(define (continuation-set! c i x) (vector-set! c (+ i 1) x))