[plt-scheme] Possible bug in for/fold

From: Dave Gurnell (d.j.gurnell at gmail.com)
Date: Sun Jun 29 06:44:11 EDT 2008

Noel wrote:
> I suppose I had never run into the difference between returning no  
> values and returning void.

This is an oddity that only became clear to me as a result of reading  
this post - obvious in hind-sight but I'd simply never thought about  
it before. I've always thought of returning void as meaning "I'm not  
returning a value" rather than "I'm returning a single value but feel  
free to ignore it."

I was going to suggest adding a paragraph like the following to the  

"When zero accumulators are specified, @scheme[for/fold] expects the  
body code to return zero values. This is the equivalent of writing  
@scheme[(values)] rather than writing @scheme[(void)], which is the  
default return value of most Scheme forms that don't have a specific  
return value."

However, having zero accumulators is an odd corner case that isn't in  
the spirit of for/fold, so I think this paragraph might confuse more  
people that it helps. Noel's for/fold was generated by a macro, which  
explains how the problem arose, but most people won't be doing this.

I guess I'm writing this post to see whether other people think the  
same thing.

-- Dave

Posted on the users mailing list.