[racket-dev] `cond' / `when' / `unless' / etc bodies

From: Eli Barzilay (eli at barzilay.org)
Date: Sun Oct 10 13:42:08 EDT 2010

A few seconds ago, Jens Axel Søgaard wrote:
> 2010/10/10 Eli Barzilay <eli at barzilay.org>:
> > I like mixing definitions and expressions -- maybe the bodies of
> > `cond' etc should also allow it?
> 
> In
> 
> >  (define (foo x)
> >    (when (even? x) (define x (add1 x)) (printf "increment\n"))
> >    x)
> 
> is the scope of the definition (define x ...) the entire body of foo ?

No, I meant that that wouldn't work.  I'm basically suggesting a
simple change -- just wrapping the bodies of these forms in a
(let () [...]).

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the dev mailing list.