Re: [racket-users] confusion about call-with-current-continuation

2018-10-26 Thread Shu-Hung You
Because applying the continuation captured by Racket's call-with-current-continuation will *replace* existing continuations. Therefore the exception handler is removed. To obtain a continuation that will only *extend* the current continuation, use call-with-composable-continuation. (Another way

Re: [racket-users] confusion about call-with-current-continuation

2018-10-26 Thread serioadamo97
Thanks Shu-hung. So here is my understanding: #lang racket (begin (define saved-k #f) ; wrapped in "prompt 1" (+ 1 (call/cc (lambda (k) (set! saved-k k) 0))) ; wrapped in "prompt 2" (println 'hello) ; wrapped in "prompt 3" (saved-k 100) ; wrapped in

Re: [racket-users] confusion about call-with-current-continuation

2018-10-25 Thread Joao Pedro Abreu De Souza
Shu-hung, very cool information. Em qui, 25 de out de 2018 às 16:57, Shu-Hung You < shu-hung@eecs.northwestern.edu> escreveu: > FWIW here's the part in the document that could be helpful: > > 1. The section in the Guide that talks about the concept of prompts > and their usage in the

Re: [racket-users] confusion about call-with-current-continuation

2018-10-25 Thread Shu-Hung You
FWIW here's the part in the document that could be helpful: 1. The section in the Guide that talks about the concept of prompts and their usage in the continuation in Racket: https://docs.racket-lang.org/guide/prompt.html The prompt is kind of like a mark on the continuations that lets the

Re: [racket-users] confusion about call-with-current-continuation

2018-10-25 Thread serioadamo97
About (+ 1 (prompt (* 2 (call/cc (lambda (k) (set! x k) 2) 1. "prompt" form does not exist in racket. It is a procedure application or special form ? 2. assume this procedure or special form exists to construct a prompt. (+ 1 (prompt (* 2 (call/cc (lambda (k) (set! x k) 2) After the

Re: [racket-users] confusion about call-with-current-continuation

2018-10-25 Thread Joao Pedro Abreu De Souza
well, let's go by parts : 1) call/cc in principle will capture the complete continuation of a expression, right? Delimited continuation will capture ... welll, delimited continuations. But delimited by what? By a prompt. In a delimited contninuation style(not really, but I dont want to mix

Re: [racket-users] confusion about call-with-current-continuation

2018-10-25 Thread serioadamo97
Thank Joao I change my code like this: #lang racket ((lambda () (define saved-k #f) (println (+ 1 (call/cc (lambda (k) ; k is the captured continuation (set! saved-k k) 0 (println 'hello) (saved-k 100) )) Now it works as I expected. But why?

Re: [racket-users] confusion about call-with-current-continuation

2018-10-25 Thread Joao Pedro Abreu De Souza
Well, call/cc is like (in racket) delimited continuation, and have a implicit prompt around a s-exp, so, as begin is a macro, he don't create a prompt. The continuation captured is (+ 1 []) in your example. If you change the begin to a let, this works, because let expand to a application of a