Marcin 'Qrczak' Kowalczyk
qrczak at knm.org.pl
Mon Oct 2 13:51:08 EDT 2006
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
And if it's allowed, then it makes a perfect sense for procedures like
vector-set! to return no values. After all, they have no meaningful
value to return.
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!.
> 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.
Sure; I'm not proposing to disallow an argument of for-each to return
a non-zero number of results. Since the results are ignored, R6RS has
adopted the convention that there can be any number of them.
> 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.
Per Bothner <per at bothner.com> writes:
> One solution (which happens to be what Kawa does, and has been
> mentioned in this discussion) is allow multiple values to be
They can't be fully first-class.
(call-with-values (lambda () x) (lambda (y) y))
This currently succeeds for any value of x, it doesn't even look inside it.
This would stop working for x being the multiple-values value.
> E.g. you can assign an expression whose result is multiple values to
> a variable, or pass it as a function parameter.
How many values is (values (values 1 2 3) (values 4 5 6))?
What about (values (values 1 2 3))? Here lies madness.
> Assume one views a declaration as an expression that evaluates to
> no values. A "body" is a compound expression that can contain
> declarations and expressions in any order, and whose result is the
> "concatenation" of the results of each sub-expression.
This would break tail calls or would require code duplication.
__("< Marcin Kowalczyk
\__/ qrczak at knm.org.pl
More information about the r6rs-discuss