[racket-dev] [plt] Push #20898: master branch updated

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Aug 23 08:40:52 EDT 2010

At Sun, 22 Aug 2010 15:36:03 -0500, "Will M. Farr" wrote:
> > Either choice --- error or stopping --- interacts awkwardly with
> > `for*/vector'. If you've going to raise an exception, the natural thing
> > to do with `for/vector' would be to stop as soon as the sequence goes
> > too far. But `for*/vector' with a length currently just uses
> > `for*/vector' without the length; you could check afterward, but that
> > would be different than the natural choice for `for/vector'.
> > 
> > Along similar lines, every `for/vector' is a `for*/vector' in a way,
> > because a `#:when' clause can introduce a nesting. The `for/vector'
> > macro with an without a length behaves very differently than the one
> > with a length when a `#:when' clause is used.
> > 
> > Maybe `for/vector' with a length clause should be syntactically
> > restricted to have no `#:when' clauses, and maybe there just shouldn't
> > be a variant of `for*/vector' that supports `#:length'.
> I'll make sure to throw a syntax error if I see a #:when in the for-clauses, 
> and I think I should give up on the for*/vector #:length variant.  I was 
> hoping that you would have some sort of neat trick to keep a running counter 
> during the nested iteration....

Maybe you want to thread the vector index through using `for/fold'
instead of drawing the index from a sequence. The expansion could
insert enough `#:when' clauses to compare the index to the length
before each nested iteration.

Posted on the dev mailing list.