Created
October 23, 2011 02:31
-
-
Save ijp/1306772 to your computer and use it in GitHub Desktop.
a bug in guiles peval
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
(define (test peval?) | |
(compile | |
'(let () | |
(define (rewind-protect thunk protector) | |
(dynamic-wind | |
(let ((entered? #f)) | |
(lambda () | |
(if entered? | |
(error "Re-entering rewind-protected extent.")) | |
(set! entered? #t))) | |
thunk | |
protector)) | |
((call/cc | |
(lambda (k) | |
(rewind-protect | |
(lambda () | |
(call/cc k) | |
(lambda _ 'not-supposed-to-happen)) | |
(lambda () #f)))) | |
#f)) | |
#:opts `(#:partial-eval? ,peval?))) | |
;; scheme@(guile−user)> (test #t) | |
;; $1 = not−supposed−to−happen | |
;; scheme@(guile−user)> (test #f) | |
;; ERROR: In procedure scm−error: | |
;; ERROR: Re−entering rewind−protected extent. | |
;; Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. | |
;; scheme@(#{ g256}#) [1]> ,q | |
;; scheme@(guile−user)> | |
;; the point of rewind-protect, is that it performs cleanup on exit, | |
;; so you can't then re-enter as the state will be | |
;; inconsistent. (Think closed database connection, etc.) What is | |
;; happening is that with partial evaluation, call/cc is ignoring the | |
;; enter-thunk, so we don't get an error, but instead continue on our | |
;; merry way. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment