[racket] "if" and internal definitions

From: Justin Zamora (justin at zamora.com)
Date: Sun Mar 16 16:38:46 EDT 2014

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)
      (define a 7)

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

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140316/9d4efd22/attachment.html>

Posted on the users mailing list.