Created
December 16, 2020 05:48
-
-
Save camoy/9643b6e73e6e6fbeeb801245e1599d05 to your computer and use it in GitHub Desktop.
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/base | |
(require racket/contract) | |
(define must-return/c | |
(make-contract | |
#:name 'must-return/c | |
#:late-neg-projection | |
(λ (blm) | |
(λ (f neg) | |
(λ args | |
(define finished? #f) | |
(dynamic-wind | |
void | |
(λ () | |
(begin0 | |
(apply f args) | |
(set! finished? #t))) | |
(λ () | |
(unless finished? | |
(raise-blame-error blm | |
#:missing-party neg | |
f | |
"procedure did not return"))))))))) | |
(define/contract (g f) | |
must-return/c | |
(f)) | |
(let/cc k | |
(g (λ () (k 42)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment