dyoo / WeScheme

29 stars 16 forks source link

call/cc is doing the wrong thing #17

Closed dyoo closed 11 years ago

dyoo commented 14 years ago

call/cc is completely broken in terms of REPL interactions. For example:

(define (make-gen gen) (let ([cont (box #f)]) (lambda () (call/cc (lambda (caller) (if (unbox cont) ((unbox cont) caller) (gen (lambda (v) (call/cc (lambda (gen-k) (begin (set-box! cont gen-k) (caller v))))))))))))

(define g1 (make-gen (lambda (return) (begin (return "a") (return "b") (return "c")))))

Calling g1 twice here does not show correct results.

dyoo commented 12 years ago

This will be fixed when Whalesong's the evaluator; we're properly prompting the continuations there.

dyoo commented 11 years ago

Following up: I'm confirming that under the prototype repl in Whalesong https://github.com/dyoo/whalesong/tree/repl this has the proper interaction:

> (define (make-gen gen) (let ([cont (box #f)]) (lambda () (call/cc (lambda (caller) (if (unbox cont) ((unbox cont) caller) (gen (lambda (v) (call/cc (lambda (gen-k) (begin (set-box! cont gen-k) (caller v)))))))))))) (define g1 (make-gen (lambda (return) (begin (return "a") (return "b") (return "c")))))
> (g1)
"a"
> (g1)
"b"
> (g1)
"c"
> (g1)
#<procedure:call/cc>
dyoo commented 11 years ago

Closing issue, with the knowledge that this is fixed in the prototype evaluator Whalesong.