per at bothner.com
Mon Oct 2 13:21:55 EDT 2006
Sam TH wrote:
> Right, when `vector-set!' produces *the unspecified value*, the program
> works fine.
One solution (which happens to be what Kawa does, and has been
mentioned in this discussion) is allow multiple values to be
first-class. E.g. you can assign an expression whose result is
multiple values to a variable, or pass it as a function parameter.
This is a somewhat radical change, but has some nice properties.
The XQuery language makes use of this.
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. Typically,
a body consists of some declarations, assignments, and other
expressions that produce no values, followed by a final expression
that produces some values. In this case the meaning of the program
does not change. What changes are bodies with multiple expressions
that produce values - these would produce multiple values.
More interestingly, the result of a loop could be the
concatenation of the values from each iteration. This leads to
a very useful algebra for constructing programs.
It might be possible to specify an R6RS with semantics based
on this idea while not break any programs that are strictly
well-defined according to R5RS. (I'm not sure; I'd have to
look at R5RS more carefully.) However, it might break a number
of real programs that are in practice fairly portable. (I'm
not sure, but I suspect so.)
Bottom line: The radical idea of redefining <body> to be a
implicit "append-values" is probably a non-starter for R6RS.
However, making multiple values be first-class is worth
seriously considering, I believe.
per at bothner.com http://per.bothner.com/
More information about the r6rs-discuss