[r6rs-discuss] "Unspecified"
On Mon, 2006-10-02 at 11:53 -0400, John Cowan wrote:
> Sam Tobin-Hochstadt scripsit:
>
> > > > (for-each/logging (lambda (x) (vector-set! v x)) indexes)
> > > >
> > > > where:
> >
> > (define (for-each/logging f l)
> > (for-each (lambda (v) (let ([w (f v)]) (display w) (newline) w)) l))
> >
> > which has the problem I was attempting to point out.
>
> What problem? Adding a proper third argument to "vector-set!", and
> defining "v" and "indexes" suitably, causes Chicken at least to simply
> print #<unspecified> as many times as there are elements of "indexes".
Right, when `vector-set!' produces *the unspecified value*, the program
works fine.
> The behavior is the same if I redefine "vector-set!" to return zero
> values, as Chicken coerces zero values to the unspecified value when
> a value is required.
This behavior is not currently portable, for example it fails in both
PLT and Chez, which error when insufficient values are provided to a
continutation.
> This is my interpretation of what R6RS requires
> as well.
This is not correct:
"Except for these [refers to implicit and explict blocks, plus
dynamic-wind] and the continuations created with the `call-with-values'
procedure, all other continuations take exactly one value. The effect
of passing an inappropriate number of values to a continuation not
created with `call-with-values' is undefined." (R5.91RS, page 50)
Therefore, both the 'coerce to the unspecified value' and the 'signal an
error' behavior are allowed by the draft. So causing `vector-set!' to
produce zero values makes my program at best unportable, and at worst
likely to error on some but not all side-effecting procedures.
sam th
Received on Mon Oct 02 2006 - 12:30:21 UTC
This archive was generated by hypermail 2.3.0
: Wed Oct 23 2024 - 09:15:00 UTC