[racket] Are these in-cycle semantics intentional?
The problem is that `in-cycle' goes into a loop trying to generate an
element. In the first case, `for' discovers that the first sequence
runs out of elements before it even asks the second sequence for an
element.
I don't see an alternative to this behavior, so I'll adjust the
documentation to describe and warn about `in-cycle' on an empty
sequence.
I'll also change `in-sequences' and `in-cycle' to accept zero
sequences, which would match the documentation, since there doesn't
seem to be a reason to require a sequence.
At Thu, 24 Nov 2011 20:57:10 -0700, Neil Toronto wrote:
> In the following program, "loop 2 finished" is never printed, even
> though `i' loops over nothing. As far as I understand, the second loop
> shouldn't iterate at all - it should stop as soon as the `i' sequence is
> finished, which is immediately. But I could be wrong, so I'm asking: is
> this a bug?
>
>
> #lang racket
>
> (for ([i (in-list empty)]
> [j (in-cycle '(1))])
> (printf "i = ~v~n" i))
>
> (printf "loop 1 finished~n")
>
> (for ([i (in-list empty)]
> [j (in-cycle empty)])
> (printf "i = ~v~n" i))
>
> (printf "loop 2 finished~n")
>
>
> Neil T