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

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sun Oct 10 14:43:42 EDT 2010

I too am in favor of when, unless, and cond being definition contexts.

But I don't understand what this fragment is supposed to illustrate.
If the body of a 'when' were a definition context, we'd get this being
the same as something like this, which seems to work exactly as it

Welcome to Racket v5.0.1.8.
> (define (foo x)
    (when (even? x) (let () (define x (add1 x)) (printf "increment\n")))
> (foo 2)
add1: expects argument of type <number>; given #<undefined>

 === context ===
stdin::1: foo

Maybe you're saying that people would be confused by that error?
Woudln't that already happen with

(define (foo x) (define x (add1 x)) x)



On Sun, Oct 10, 2010 at 11:43 AM, Eli Barzilay <eli at barzilay.org> wrote:
> I like mixing definitions and expressions -- maybe the bodies of
> `cond' etc should also allow it?
> The only downside I see is the possible confusion in somthing like
>  (define (foo x)
>    (when (even? x) (define x (add1 x)) (printf "increment\n"))
>    x)
>  ;; why isn't this working?
> but that seems like a minor point (without that `printf' you'd still
> get a syntax error; and the same confusion can already happen with
> `let' etc).
> --
>          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
>                    http://barzilay.org/                   Maze is Life!
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/dev

Posted on the dev mailing list.