shift/control broken

This commit is contained in:
Yuichi Nishiwaki 2014-05-19 20:35:31 +09:00
parent 5c59dcd564
commit 8388e8ed33
2 changed files with 15 additions and 15 deletions

View File

@ -65,8 +65,6 @@ Picrin is a lightweight scheme implementation intended to comply with full R7RS
- `(reset h)`
- `(shift k)`
- `(prompt h)`
- `(control k)`
delimited control operators

View File

@ -5,26 +5,28 @@
(define m #f)
(define (abort t)
(let ((v (t))) ; (t) may update m. do not place me like (m (t))
(m v)))
(define (reset t)
(let ((n m))
(call/cc
(lambda (k)
(let ((n m))
(set! m (lambda (r)
(set! m n)
(k r)))
(t)))))
(abort t)))))
(define (shift h)
(call/cc
(lambda (k)
(abort
(lambda ()
(h (lambda (v)
(reset (lambda ()
(k v))))))))
(define prompt reset)
(define control shift)
(k v))))))))))
(export shift
reset
control
prompt))
reset))