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

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Aug 19 18:57:56 EDT 2010

At Thu, 19 Aug 2010 18:45:43 -0400, samth at racket-lang.org wrote:
> +(define-syntax for*/flvector
> +  (lambda (stx)
> +    (syntax-case stx ()
> +      ((for*/flvector (for-clause ...) body)
> +       (syntax/loc stx
> +         (list->flvector (for*/list (for-clause ...) body))))
> +      ((for*/flvector length-expr (for-clause ...) body)
> +       (syntax/loc stx
> +         (for*/flvector (for-clause ...) body))))))

I'm not comfortable with overloading based on the number of forms (the
same with `for/vector' and `for*/vector'), since the `for' forms
normally allow multiple expressions and internal definitions in the
`for' body.

It would be better to use a `#:size' keyword when supplying a specific
size instead of relying on the number of forms within `for/vector'.

> + at defform*[((for/vector (for-clause ...) body)
> +           (for/vector length-expr (for-clause ...) body))]

Along the same lines: the `body' meta-variable must always be followed
by `...+' in a syntax description. If you allow only one expression,
it's `expr' insteda of `body'. (But I think the solution here is to
change the syntax so that the docs will have `body ...+'.)

> + at defform*[((for*/vector (for-clause ...) body)
> +           (for*/vector length-expr (for-clause ...) body))])]{
> +
> +Iterates like @scheme[for] or @scheme[for*], but the values of the
> + at scheme[body] expression are placed in a vector whose length is the
> +number of iterations.  The optional @scheme[length-expr], if present,
> +is evaluated to determine the length of the vector in advance of the
> +iteration; if @scheme[length-expr] is provided, the computation is
> +more efficient.}

The documentation doesn't answer the question that you asked before,
which is what happens when the result of `length-expr' doesn't match
the number of iterations. There appear to be no tests for that case,

Posted on the dev mailing list.