Created
February 21, 2025 13:13
-
-
Save dannypsnl/50e0b0aa8c83d70433b639234fa81f1d to your computer and use it in GitHub Desktop.
Get chez scheme stuck
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (import (chezscheme)) | |
| (define handler-key (gensym)) | |
| (define th #f) | |
| (define x 0) | |
| (define (sub) | |
| (define n | |
| (call/cc (lambda (k) | |
| (define abort (continuation-marks-first (current-continuation-marks) handler-key)) | |
| (abort k)))) | |
| (set! x (+ x n))) | |
| (write x) | |
| (newline) | |
| (with-continuation-mark | |
| handler-key (lambda (resume) | |
| (set! th (fork-thread (lambda () (resume 20)))) | |
| (resume 10)) | |
| (sub)) | |
| (write x) | |
| (newline) | |
| (thread-join th) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you resume the current stack from another thread, and also resume it in the current thread: blocked.
More interesting, if you don't do
resumein the current thread, but only invoke it from another thread:+will receive a second call with bad arguments:Which means
(resume)happened 2 times.