Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mutation of environments while capturing continuations with call/cc #257

Open
jcubic opened this issue Aug 15, 2021 · 0 comments
Open

Mutation of environments while capturing continuations with call/cc #257

jcubic opened this issue Aug 15, 2021 · 0 comments
Labels

Comments

@jcubic
Copy link
Contributor

jcubic commented Aug 15, 2021

Just found interesting case of continuations that break in Biwascheme:

(call/cc (lambda (return)
           (let ((n 5)
                 (result (list))
                 (k #f))
             (set! result (append result (list (call/cc (lambda (return)
                                                          (set! k return)
                                                          "Hello")))))
             (when #t
               (if (zero? n)
                   (return result))
               (set! n (- n 1))
               (k (string-append "Hello <" (number->string n) ">"))))))

This should evaluate to ("Hello <0>") because the reference to result is kept in continuation, and the env is restored on each iteration and it gets reset to an empty list.
I've tested this in Guile, Gamibt and Chicken they all return a list with the last element. BiwaScheme return list of all elements.

@yhara yhara added the bug label Aug 24, 2021
@jcubic jcubic changed the title Mutation of environments while capturing continuations Mutation of environments while capturing continuations with call/cc Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants