[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can array-ref return (values ...) ?

Brad Lucier writes:

> I'm trying to put together an implementation of arrays that will
> serve my current purposes.  At one point, I basically wanted
> (array-ref a i j k ...)
> to return (values ...).
> So I looked at this SRFI and it doesn't seem that this is a real
> problem (OK, it would be a problem with array-set!, but perhaps one
> wants read-only arrays without array-set! to be possible.)

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.

If you want something that accesses several elements at one time - is
that a one-dimensional array above? - that would just be another
operation. No problem.

> How pervasively does one want multiple values to insinuate itself
> into the rest of the language?

I wouldn't avoid them when they are appropriate.

One consideration is what you can do with the values. They must be
passed to a procedure, and that either knows their number or turns
them into a list. In the latter case, it might be better to return a
list or an array in the first place.