[racket] begin vs +

From: Laurent (laurent.orseau at gmail.com)
Date: Mon Aug 2 09:31:44 EDT 2010

On Mon, Aug 2, 2010 at 15:23, Keiko Nakata <keiko at kurims.kyoto-u.ac.jp>wrote:

> Hi,
>
> From: Matthew Flatt <mflatt at cs.utah.edu>
>
> > At Mon, 02 Aug 2010 21:54:54 +0900 (JST), Keiko Nakata wrote:
> > > Why this code
> > >
> > > (let ([d (box #f)] [a (box 0)])
> > >   (print (+ (begin (let/cc k (begin (set-box! d k) (set-box! a 2) 3)))
> (unbox
> > > a)))
> > >   ((unbox d) 9))
> > >
> > > prints 511111111, rather than 59999999?
> >
> > I'm not sure I'm following. Can you say more about why you expect
> > infinite "9"s instead of infinite "11"s?
>
> I wanted to undo the assignment (set-box! d k), but I think I am confusing.
> I'm a novice to continuations...
>
> I used begin to enforce sequentiality, but seemed to be trapped by it.
>

Maybe you could use `(let () *body ...*)' instead? It should be closer to
your intentions.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100802/6268db96/attachment.html>

Posted on the users mailing list.