|
|
ToDo:
|
|
(define (test)
(let ((i 0))
(lambda()
(set! i (+ i 1))
i)))
とすると
gosh> (define a (test)) a gosh> (a) 1 gosh> (a) 2 gosh> (a) 3では継続を使うと…
(define *cont* #f)
(define (test)
(let ((i 0))
(call/cc (lambda(c)(set! *cont* c)))
;-- 継続はここから
(set! i (+ i 1))
i))
で
gosh> (define a test) a gosh> (a) 1 gosh> (a) 1 gosh> (*cont*) 2 gosh> (*cont*) 3 gosh> (test) 1 gosh> (*cont*) 2です。 viaContinuation - Wikipedia 継続も関数同様にfirst classなんですな。