[racket] Typed Racket and macros expanding to for*:

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Wed Jul 25 17:56:38 EDT 2012

On Jul 25, 2012, at 5:51 PM, Jens Axel Søgaard wrote:

> 2012/7/25 Matthias Felleisen <matthias at ccs.neu.edu>:
>> 
>> Yes, the #:when clause has to be last. I got my reasoning backwards.
>> 
>> Do try both and report back. I am curious how expensive the ec is compared
>> to the #:when test.
> 
> It turned out that the for*/fold + #:when solution didn't behave as expected.
> Here is the documentation of for/vector :
> 
> --
> 
> (for/vector (for-clause ...) body ...+)
> (for/vector #:length length-expr (for-clause ...) body ...+)
> 
> Iterates like for/list, but the result are accumulated into a vector
> instead of a list. If the optional #:length form is used, then
> length-expr must evaluate to an exact-nonnegative-integer?, and the
> result vector is constructed with this length. In this case, the
> iteration can be performed more efficiently, and terminates when the
> vector is full or the requested number of iterations have been
> performed, whichever comes first.
> 
> --
> 
> I interpret this paragraph to mean, that
> 
>     (for/vector #:length 10 ([i (in-naturals)]) i)
> 
> ought to terminate - but it doesn't !
> 
> The question is now, whether the bug is in the documentation, the implementation
> or my interpretation.


There is certainly a conflict between the docs and the behavior. 

I think the docs describe the desirable behavior so I suggest you
submit a bug report against the code. If this is wrong, I am sure 
Matthew will let us know. 



Posted on the users mailing list.