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 should:
Welcome to Racket v5.0.1.8. > (define (foo x) (when (even? x) (let () (define x (add1 x)) (printf "increment\n"))) x) > (foo 2) add1: expects argument of type <number>; given #<undefined> === context === stdin::1: foo /home/robby/git/gr2/collects/racket/private/misc.rkt:74:7 > 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) ? Robby On Sun, Oct 10, 2010 at 11:43 AM, Eli Barzilay <e...@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 > _________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev