I agree that #:while and #:until are easily confused with #:when and #:unless. I slightly prefer #:stop- to #:break- as a prefix here, it seems a more natural word. I like the idea of allowing these clauses at the end of the body to give a notion of stopping after the current iteration. I had been wondering how to do that, and hadn't come up with anything nearly so simple.<br>
<br>On Fri, Sep 14, 2012 at 11:40 AM, Matthew Flatt <span dir="ltr"><<a href="mailto:mflatt@cs.utah.edu" target="_blank">mflatt@cs.utah.edu</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I think this is a good idea. The technique to implement it is embedded<br>
in `for/vector' (to handle a vector length), and I can generalize that<br>
and move it into `for...'.<br>
<br>
Also, I think the names `#:while' and `#:until' are too close to<br>
`#:when' and `#:unless'. I suggest `#:break-when' and `#:break-unless'.<br>
Compare:<br>
<br>
> (for*/list ([j 2] [i 10] #:when (i . < . 5)) i)<br>
'(0 1 2 3 4 0 1 2 3 4)<br>
> (for*/list ([j 2] [i 10] #:break-unless (i . < . 5)) i)<br>
'(0 1 2 3 4)<br>
<br>
I imagine that `#:break-when' and `#:break-unless' are allowed among<br>
the clauses much like `#:when' and `#:unless', but also allowed at the<br>
end of the body. Is that what you had in mind?<br><div><div class="h5">
<br>
At Fri, 14 Sep 2012 10:09:52 -0400, Carl Eastlund wrote:<br>
> I would like the for/... comprehension macros to have #:while and #:until<br>
> clauses similar to the #:when and #:unless clauses. I often find I want to<br>
> short-circuit the sequence at some point, but there is no elegant way to do<br>
> it. I could probably write sequence-while and sequence-until, but I don't<br>
> want to move this condition into the sequence any more than I want to write<br>
> sequence-filter instead of #:when or #:unless.<br>
><br>
> Has this been brought up before? I can't recall. Does anyone else run<br>
> into the same issue?<br>
><br>
> Carl Eastlund<br>
</div></div>> _________________________<br>
> Racket Developers list:<br>
> <a href="http://lists.racket-lang.org/dev" target="_blank">http://lists.racket-lang.org/dev</a><br>
<br>
</blockquote></div><br>