@abcdw see call/cc definition in (hoot prelude)
3 comments
@wingo It seems to preserve the semantics of call/cc, but probably there are some shortcomings in this implementation. P.S. Oops, it doesn't preserve the semantics. @wingo I like the idea to make a default-prompt-tag a parameter: https://gitlab.com/spritely/guile-hoot/-/blob/main/module/hoot/prelude.scm?ref_type=heads#L328 I also find your implementation quite similiar to what I tried to do with shift/reset above. Thank you for sharing! |
@wingo Thank you, I'll take a look!
ATM I worked around it like this:
(begin
(define (my-call/cc f)
(shift k (k (f k))))
(define (my-eval exp)
(reset
(primitive-eval exp)))
(my-eval `(define kont #f))
(my-eval `(+ 1 (my-call/cc (lambda (k) (set! kont k) 5))))
(my-eval `(kont 41)))
But don't know how good this idea is :)
I have another plan on how to improve the evaluation thread implementation, so call/cc doesn't break the value returning and interruption mechanisms.
@wingo Thank you, I'll take a look!
ATM I worked around it like this:
(begin
(define (my-call/cc f)
(shift k (k (f k))))
(define (my-eval exp)
(reset
(primitive-eval exp)))
(my-eval `(define kont #f))
(my-eval `(+ 1 (my-call/cc (lambda (k) (set! kont k) 5))))
(my-eval `(kont 41)))
But don't know how good this idea is :)