adding call/ec
This commit is contained in:
parent
d9df598fe1
commit
7159c40459
|
@ -15,11 +15,13 @@
|
||||||
(all-from-out "list.rkt")
|
(all-from-out "list.rkt")
|
||||||
(all-from-out "private/map.rkt")
|
(all-from-out "private/map.rkt")
|
||||||
(all-from-out "private/hash.rkt")
|
(all-from-out "private/hash.rkt")
|
||||||
|
(all-from-out "private/call-ec.rkt")
|
||||||
quasiquote)
|
quasiquote)
|
||||||
|
|
||||||
(require "private/list.rkt"
|
(require "private/list.rkt"
|
||||||
"private/map.rkt"
|
"private/map.rkt"
|
||||||
"private/hash.rkt"
|
"private/hash.rkt"
|
||||||
|
"private/call-ec.rkt"
|
||||||
"list.rkt"
|
"list.rkt"
|
||||||
(only-in "private/qq-and-or.rkt" quasiquote))
|
(only-in "private/qq-and-or.rkt" quasiquote))
|
||||||
|
|
||||||
|
|
27
whalesong/lang/private/call-ec.rkt
Normal file
27
whalesong/lang/private/call-ec.rkt
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#lang s-exp "../kernel.rkt"
|
||||||
|
|
||||||
|
(require (for-syntax racket/base
|
||||||
|
syntax/parse))
|
||||||
|
|
||||||
|
(provide call-with-escape-continuation
|
||||||
|
call/ec
|
||||||
|
let/ec)
|
||||||
|
|
||||||
|
|
||||||
|
(define (call-with-escape-continuation proc)
|
||||||
|
(define p (make-continuation-prompt-tag))
|
||||||
|
(call-with-continuation-prompt
|
||||||
|
(lambda ()
|
||||||
|
(proc (lambda args
|
||||||
|
(abort-current-continuation p (lambda ()
|
||||||
|
(apply values args))))))))
|
||||||
|
|
||||||
|
(define call/ec (procedure-rename call-with-escape-continuation 'call/ec))
|
||||||
|
|
||||||
|
|
||||||
|
(define-syntax (let/ec stx)
|
||||||
|
(syntax-parse stx
|
||||||
|
[(_ name:id body:expr ...+)
|
||||||
|
(syntax/loc stx
|
||||||
|
(call-with-escape-continuation (lambda (name)
|
||||||
|
body ...)))]))
|
|
@ -12,6 +12,7 @@
|
||||||
(require "base.rkt"
|
(require "base.rkt"
|
||||||
"private/traced-app.rkt"
|
"private/traced-app.rkt"
|
||||||
"private/shared.rkt"
|
"private/shared.rkt"
|
||||||
|
"private/call-ec.rkt"
|
||||||
"check-expect/check-expect.rkt"
|
"check-expect/check-expect.rkt"
|
||||||
"bool.rkt"
|
"bool.rkt"
|
||||||
"posn.rkt"
|
"posn.rkt"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user