What is the reason for not allowing internal definitions in the "then" and
"else" parts of an "if"?

This fails with "define: not allowed in an expression context":
(if (< 3 4)
    5
    (begin
      (define a 7)
      a))

But the equivalent "cond" works fine:
(cond
  [(< 3 4) 5]
  [else (define a 7)
          a])

I notice that the expansion of "cond" encloses the clauses inside
(let-values () ...). Why doesn't "if" allow this?

Justin
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to