[plt-scheme] send/suspend + sandbox + exceptions = strange thing
A week ago I asked about how to integrate send/suspend with sandbox.
"send/suspend" is for web, it use continuations
Sandboxes broke continuations, but I need send/suspend which can work with multiple sandboxes.
I wrote my own "send/suspend!", using exceptions: in sandbox it raise exception with argument for send/suspend, and running eval with exception handler allow to call usual send/suspend otside of sandbox
(define send/suspend! (lambda (f)
;;prepare f for out-of-sandbox
(raise (list 'send/suspend! f))))
;;predicate for send/suspend! exception
(define exn:Socium-eval:send/suspend!? (lambda (exn)
(and (list? exn)
(not (empty? exn))
(equal? (car exn) 'send/suspend!))))
;; "send/suspend!" exception handler
(define exn-handler:send/suspend! (lambda (exn)
;;(lambda (k-url) ...) for "send/suspend"
(define f (cadr exn))
;;make usual "send/suspend"
;;return to continuation with send/suspend value
;;(jump in sandbox again)
;;this value will be on the place of exception
(send/suspend f)
))
(define sandbox-eval ( ............
............
............
(define e (personal-evaluator e-mail))
;;eval expr
;;(with exceptions handling)
(with-handlers ([exn:Socium-eval:send/suspend!? exn-handler:send/suspend!])
(e expr))
............
............
))
and got some strange trouble: when I run my web application, with just one call of "send/suspend!", I see some web page what I need,
but when I press "submit" there, I got error:
broke the contract
(->*
((-> request? response?))
... ... ... ... ...
)
on serve/servlet; expected <response?>, given: #<request>
I started to discover, where program breaks ...
it happens later than exn-handler:send/suspend! , but before returning to send/suspend! from exception handler
if I put message "hello world" instead of send/suspend returned #<request> in exn-handler:send/suspend!, I really can see it in browser instead of page
how can it be, what is it?