[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: vectors are something else
From: |
Daniel Hartwig |
Subject: |
Re: vectors are something else |
Date: |
Fri, 12 Apr 2013 07:53:02 +0800 |
On 11 April 2013 07:07, Daniel Llorens <address@hidden> wrote:
>
> After the array-map patches, I've gone through the vector/array
> implementation and there's some stuff I'd like to fix. In stable-2.0 today:
>
> (define a (make-typed-array ''f64 0 '(1 2))
> a
> => address@hidden(0.0 0.0)
>
> so far so good.
>
> (uniform-vector? a)
> => #t
>
> (f64vector-ref? a)
> => #t
>
> so far so good.
>
> (uniform-vector-ref a 0)
> => 0.0
>
> This is a bug, since the valid indices are 1 and 2. This bug is in
> scm_c_generalized_vector_ref (and elsewhere):
For a vector, the valid indices are as specified by r5rs:
The _valid indexes_ of a vector are the exact non-negative
integers less than the length of the vector. The first element in a
vector is indexed by zero, and the last element is indexed by one less
than the length of the vector.
which applies even when accessing arrays as vectors. Offset indexing
is a feature of the array interface only.