[racket] Unreachable line reached
On 17/09/12 18:30, Danny Yoo wrote:
>> I have a trivial question but I desperately need a spare pair or eyes (or
>> another brain).
>
> The 'when's here look really suspicious. You want control flow to go
> exclusively to one or the other path, but when you have 'when' like
> this:
>
>
> ... (when <test> <body>) <rest>
>
> unless an exception occurs in the <test> or <body>, control flow will
> inevitably go through <rest> as well. And I suspect you _don't_ want
> that in your use in the snippet.
>
Even before trying your solution (which I am pretty sure it will ok),
let me ask you to confirm my suspicion.
Initially my idea was:
(when <cond>
<stmt>s
(loop (read-line in)))
<rest>
If <cond> is true, <rest> will never execute because we are looping with
read-line.
However, after your email I can see that after (loop (read-line in))
finishes <rest> is going to be executed. And this _has_ to be executed
unless there was a return or exception in the function, but since we are
in Racket and I am not playing with call/cc, <rest> will be executed no
matter what.
As you can see, I have been doing imperative languages for too long now.
Need to get back into racket. :)
Thanks,
--
PMatos