samth at ccs.neu.edu
Mon Oct 2 14:09:11 EDT 2006
On Mon, 2006-10-02 at 19:51 +0200, Marcin 'Qrczak' Kowalczyk wrote:
> Sam TH <samth at ccs.neu.edu> writes:
> >> 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'.
> Then write it correctly, accepting any number of values.
> That someone wants to write sloppy logging code is not a sufficient
> excuse for disallowing returning any number of values by the argument
> of for-each.
It's written correctly, it just doesn't accept all the possible
arguments that `for-each' does. `map' is also not a drop-in replacement
for `for-each', but I don't think `map' is written incorrectly.
It's also code that works perfectly well in many Scheme systems today.
You're suggesting that any time a function is used as an argument, the
code is incorrect if it doesn't expect that function to potentially
return multiple values. Alternatively, that higher-order functions
should not be used with side-effecting procedures as their arguments.
Neither of these seems like it has any benefits for anyone.
> It's good that this would be an error because it catches certain bugs
> earlier, namely using the result of a function like vector-set!.
I disagree that the example I've posted in this thread is a bug. It
doesn't print especially useful information, but you're suggesting that
it be an error. What if the function occasionally did something more
interesting than vector-set!?
> > Many programs that take function arguments break in these cases -
> > which was precisely my point.
> Do you want to disallow an argument of for-each to return a different
> number of results than 1? If yes, this is inconsistent with other
> context which use a function for side effects only. If not, the code
> which assumes 1 result is already incorrect.
At no point was the argument to `for-each' assumed to return any number
of results. I defined a function that expects a functional argument,
which must take one argument and return one result. I then used
`for-each' to implement that function.
You seem to think the function I wrote should either be significantly
more complex, or that certain standard procedures should be specified so
that they don't work with my function. What advantage is being gained
More information about the r6rs-discuss