adding call/ec

This commit is contained in:
Danny Yoo 2013-04-18 15:54:08 -06:00
parent d9df598fe1
commit 7159c40459
3 changed files with 30 additions and 0 deletions

View File

@ -15,11 +15,13 @@
(all-from-out "list.rkt")
(all-from-out "private/map.rkt")
(all-from-out "private/hash.rkt")
(all-from-out "private/call-ec.rkt")
quasiquote)
(require "private/list.rkt"
"private/map.rkt"
"private/hash.rkt"
"private/call-ec.rkt"
"list.rkt"
(only-in "private/qq-and-or.rkt" quasiquote))

View 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 ...)))]))

View File

@ -12,6 +12,7 @@
(require "base.rkt"
"private/traced-app.rkt"
"private/shared.rkt"
"private/call-ec.rkt"
"check-expect/check-expect.rkt"
"bool.rkt"
"posn.rkt"