[racket] how does call/cc and let/ec exactly works?
thank you for your replying
does call/cc always working with let/ec?
when it comes to compare with your code, it looks like..
call/cc is meaning of "get out of this function and evaluate next function
and comeback (to inside of let/ec) for evaluate rest of the code"
is it right?
if so, I don't understand why
following code does not working properly
#lang scheme
(require racket/gui)
(define (aa) #t #f "11")
(dynamic-wind
(lambda () (display "in "))
(lambda ()
(display "pre ")
(let/ec out
(display (call/cc out)))
(display "1")
(display "2")
(display "3")
)
(lambda () (display "out ")))
but the following code works weird
#lang scheme
(require racket/gui)
(define (aa) #t #f "11")
(dynamic-wind
(lambda () (display "in "))
(lambda ()
(display "pre ")
(let/ec out
(display (call/cc out)))
(display "1")
(display "2")
(display "3")
"1")
(lambda () (display "out ")))
2010년 10월 18일 오후 7:59, Jos Koot <jos.koot at telefonica.net>님의 말:
> Compare yoiur code with:
>
> #lang scheme
>
> (require racket/gui)
>
> (dynamic-wind
> (lambda () (display "in "))
> (lambda ()
> (display "pre ")
> (let/ec out
>
> (display (call/cc out)))
> #f)
> (lambda () (display "out ")))
>
> Jos
>
> ------------------------------
> *From:* users-bounces at racket-lang.org [mailto:
> users-bounces at racket-lang.org] *On Behalf Of *???
> *Sent:* 18 October 2010 12:41
> *To:* users at racket-lang.org
> *Subject:* [racket] how does call/cc and let/ec exactly works?
>
> hello
> I am thinking of such a code like..
> #lang scheme
> (require racket/gui)
> (let ([v (let/ec out
> (dynamic-wind
> (lambda () (display "in "))
> (lambda ()
> (display "pre ")
> (display (call/cc out))
> #f)
> (lambda () (display "out "))))])
> (when v (v "post ")))
>
> but I still have no idea how
> "in pre out in post out " is printed but not "in pre out in pre post out "
> how does call/cc and let/ec exactly works?
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20101018/a6f41761/attachment.html>