<p dir="ltr">Ok, but why is "cond" defined to behave differently? I expected "cond" to behave the same as "if".</p>
<p dir="ltr">Justin</p>
<div class="gmail_quote">On Mar 16, 2014 4:59 PM, "Jens Axel Søgaard" <<a href="mailto:jensaxel@soegaard.net">jensaxel@soegaard.net</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The problem is that  begin  does not introduce a new scope.<br>
You can use (let () ...) or block instead.<br>
<br>
<a href="http://docs.racket-lang.org/reference/block.html?q=block#%28form._%28%28lib._racket%2Fblock..rkt%29._block%29%29" target="_blank">http://docs.racket-lang.org/reference/block.html?q=block#%28form._%28%28lib._racket%2Fblock..rkt%29._block%29%29</a><br>

<br>
/soegaard<br>
<br>
<br>
2014-03-16 21:38 GMT+01:00 Justin Zamora <<a href="mailto:justin@zamora.com">justin@zamora.com</a>>:<br>
> What is the reason for not allowing internal definitions in the "then" and<br>
> "else" parts of an "if"?<br>
><br>
> This fails with "define: not allowed in an expression context":<br>
> (if (< 3 4)<br>
>     5<br>
>     (begin<br>
>       (define a 7)<br>
>       a))<br>
><br>
> But the equivalent "cond" works fine:<br>
> (cond<br>
>   [(< 3 4) 5]<br>
>   [else (define a 7)<br>
>           a])<br>
><br>
> I notice that the expansion of "cond" encloses the clauses inside<br>
> (let-values () ...). Why doesn't "if" allow this?<br>
><br>
> Justin<br>
><br>
> ____________________<br>
>   Racket Users list:<br>
>   <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
><br>
<br>
<br>
<br>
--<br>
--<br>
Jens Axel Søgaard<br>
</blockquote></div>