Created
February 2, 2022 19:25
-
-
Save benknoble/0e33f876bd254deedf959c29175b51d6 to your computer and use it in GitHub Desktop.
REPL with return
This file contains 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
#lang racket | |
(define-namespace-anchor this-module) | |
(displayln 'start) | |
(displayln `(repl ,(call/ec (λ (return-k) | |
(parameterize ([current-namespace (namespace-anchor->namespace this-module)]) | |
(namespace-set-variable-value! 'return return-k #f (current-namespace) #t) | |
(read-eval-print-loop)))))) | |
(displayln 'end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A possible variant could set exit-handler (https://docs.racket-lang.org/reference/Exiting.html#%28def._%28%28quote._~23~25kernel%29._exit-handler%29%29)