Sam,

On Aug 18, 2010, at 1:39 PM, Sam Tobin-Hochstadt wrote:

>> 
>> The for/... forms have the option of having a first expression that gives 
>> the length of the resulting object (similar to srfi-42's vector-of-length-ec 
>> form) to allow generating more efficient code:
>> 
>> (for/vector ((x (in-range 3))) x) => (vector 0 1 2)
>> (for/vector 3 ((x (in-range 3))) x) => (vector 0 1 2) ; but more efficiently
> 
> What does this do if the specified length is wrong?

If the length is too short, then there will be a vector access error with the 
correct syntax location (though it may be a bit cryptic); if the length is too 
long, then the returned vector will have some slots at the end that are 
undefined (i.e. filled with whatever (make-vector NN) produces).  I think this 
kinda sucks, but I don't see any way to grab the length of a (for ...) form 
before it's run to check for consistency (in fact, I'm pretty sure you can't, 
since for loops can have #:while clauses that turn computation of the length 
into the halting problem).  In my opinion, offering the fast path (the slow 
path makes a list first, then calls (list->vector ...) on the result, so the 
fast path should be a big win both in memory and speed) is worth the risk, but 
I'd be interested to hear what you think.

I'm currently preparing the patch you requested; I'll let you know when it 
compiles and passes the tests on my system (which takes a while, since I have 
to build the whole racket environment).

Will
_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev

Reply via email to