Re: Can array-ref return (values ...) ?
David Rush 20 Feb 2002 18:40 UTC
Brad Lucier <xxxxxx@math.purdue.edu> writes:
> > Brad Lucier <xxxxxx@math.purdue.edu> writes:
> > > > I don't understand. Array-ref by me returns the contents of a single
> > > > element, so that would be just (values v) which is just v.
> > >
> > > Yes, it returns the contents of a single element, but what are the contents
> > > of a single element? ... Can it be
> > > (values a b)? If not, why not?
> >
> > No. Because (values ...) is not a data constructor. It is a special
> > syntax that explicitly applies its arguments to the current
> > continuation [see the recent messages on cls under the TCO thread].
>
> In R5RS, (values ...) is a procedure.
Ok, it's a procedure that accesses the current continuation
then. It is a very odd procedure in since it can only be called in
tail position. It *still* does not construct a data object, so it
cannot be the "contents" of an array element. IOW,
(vector-set! v n (values 4 3 2))
is completely meaningless. Therefore the contents of a single element
cannot be (values a b).
> > > And if not, perhaps it should be
> > > documented to be not possible.
> >
> > OK. Except that it's really not possible because of R5RS.
> R5RS has nothing at all to say about arrays (or many other things).
> So we are free to use our imagination, if we wish.
But it has lots to say about tail calls and continuations. VALUES is a
continuation operator, not a data constructor.
david rush
--
Scheme: Because continuations are freaky.
-- Anton van Straaten (the Scheme Marketing Dept from c.l.s)