[r6rs-discuss] "Unspecified"
Sam TH
samth at ccs.neu.edu
Mon Oct 2 12:56:17 EDT 2006
On Mon, 2006-10-02 at 18:18 +0200, Marcin 'Qrczak' Kowalczyk wrote:
> Sam Tobin-Hochstadt <samth at ccs.neu.edu> writes:
>
> > (define (for-each/logging f l)
> > (for-each (lambda (v) (let ([w (f v)]) (display w) (newline) w)) l))
>
> The results of applications of the argument of for-each are ignored;
> there is no reason to log them.
It is precisely because the results are ignored that I would need to
write `for-each/logging'. As to when it might be useful, not every
side-effecting procedure returns no information, just like not every
procedure used as a predicate returns only booleans.
> If you absolutely want to, you should check the number of results
> instead of assuming that there is exactly one result. The argument
> of for-each is allowed to return any number of results.
It is true that `for-each/logging' doesn't work if the procedure
argument sometimes returns multiple values (or zero values), and thus
isn't always a drop-in replacement for `for-each'. Many programs that
take function arguments break in these cases - which was precisely my
point. We shouldn't make more special cases that have to be coded for,
when we can allow the standard case to work.
sam th
More information about the r6rs-discuss
mailing list