我使用guile 2.0.13
作为我的方案解释器,我编写了文件3.3.3.scm
,如下所示:
(define lwp-list '())
(define quit-k #f)
(define lwp
(lambda (thunk)
(set! lwp-list (append lwp-list (list thunk)))))
(define start
(lambda ()
(if (not quit-k)
(set! quit-k (call/cc (lambda (k) k))))
(if (not (null? lwp-list))
(let ([p (car lwp-list)])
(set! lwp-list (cdr lwp-list))
(p)))))
(define pause
(lambda ()
(call/cc
(lambda (k)
(lwp (lambda () (k #f)))
(start)))))
(define quit
(lambda ()
(set! lwp-list '())
(quit-k #f)))
(lwp (lambda () (let f () (pause) (display "h") (f))))
(lwp (lambda () (let f () (pause) (display "e") (f))))
(lwp (lambda () (let f () (pause) (display "y") (f))))
(lwp (lambda () (let f () (pause) (display "!") (f))))
(lwp (lambda () (let f () (pause) (newline) (f))))
(lwp (lambda () (let f () (pause) (quit))))
(start)
如果我在交互界面中使用3.3.3.scm
,(load "3.3.3.scm")
似乎运行正常。但是当我直接运行guile 3.3.3.scm
时,将在quit
第一次调用后调用过程guile
:
hey!
Backtrace:
In ice-9/boot-9.scm:
160: 3 [catch #t #<catch-closure 17db460> ...]
In unknown file:
?: 2 [apply-smob/1 #<catch-closure 17db460>]
In ice-9/boot-9.scm:
66: 1 [call-with-prompt prompt0 ...]
In unknown file:
?: 0 [#f #f]
ERROR: In procedure #f:
ERROR: Wrong type to apply: #f
这种差异是什么情况?