Skip to content

Instantly share code, notes, and snippets.

@nkoguro
Created June 1, 2020 07:04
Show Gist options
  • Save nkoguro/3bfdabdf23e12825c03fd8d2f93c9a7c to your computer and use it in GitHub Desktop.
Save nkoguro/3bfdabdf23e12825c03fd8d2f93c9a7c to your computer and use it in GitHub Desktop.
(use data.queue)
(use gauche.partcont)
(define queue (make-queue))
(define (wrap thunk)
(lambda ()
(guard (e (else (print "catch!")
(raise e)))
(reset
(thunk)))))
(define (yield)
(shift cont
(enqueue! queue (wrap cont))))
(define (main args)
(enqueue! queue (wrap (lambda ()
(let1 counter 0
(while #t
(inc! counter)
(when (= counter 10)
(error "err"))
(yield))))))
(while #t
(let1 next (dequeue! queue #f)
(when next
(next))))
0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment