目前,我在函数式语言中试验continuation的时候,我的理解是一个continuation记录了当前的程序计数器和寄存器文件,当一个continuation返回时,PC和注册的文件就会恢复到它记录的值.
因此,在以下来自Might 博客文章的愚蠢示例中,
; right-now : -> moment
(define (right-now)
(call-with-current-continuation
(lambda (cc)
(cc cc))))
; go-when : moment -> ...
(define (go-when then)
(then then))
; An infinite loop:
(let ((the-beginning (right-now)))
(display "Hello, world!")
(newline)
(go-when the-beginning)) ; here the-beginning continuation passed to go-when, which ultimately will have an continuation applied to an continuation, that returns a continuation, which will cause the the program point resumed to the PC and registers states recorded in it.
我不确定我的理解是否正确..如果您认为不正确,请纠正我....