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.
On Fri, Sep 14, 2012 at 11:40 AM, Matthew Flatt <mfl...@cs.utah.edu> wrote: > I think this is a good idea. The technique to implement it is embedded > in `for/vector' (to handle a vector length), and I can generalize that > and move it into `for...'. > > Also, I think the names `#:while' and `#:until' are too close to > `#:when' and `#:unless'. I suggest `#:break-when' and `#:break-unless'. > Compare: > > > (for*/list ([j 2] [i 10] #:when (i . < . 5)) i) > '(0 1 2 3 4 0 1 2 3 4) > > (for*/list ([j 2] [i 10] #:break-unless (i . < . 5)) i) > '(0 1 2 3 4) > > I imagine that `#:break-when' and `#:break-unless' are allowed among > the clauses much like `#:when' and `#:unless', but also allowed at the > end of the body. Is that what you had in mind? > > At Fri, 14 Sep 2012 10:09:52 -0400, Carl Eastlund wrote: > > I would like the for/... comprehension macros to have #:while and #:until > > clauses similar to the #:when and #:unless clauses. I often find I want > to > > short-circuit the sequence at some point, but there is no elegant way to > do > > it. I could probably write sequence-while and sequence-until, but I > don't > > want to move this condition into the sequence any more than I want to > write > > sequence-filter instead of #:when or #:unless. > > > > Has this been brought up before? I can't recall. Does anyone else run > > into the same issue? > > > > Carl Eastlund > > _________________________ > > Racket Developers list: > > http://lists.racket-lang.org/dev > >
_________________________ Racket Developers list: http://lists.racket-lang.org/dev