[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: make-shared-array and bitvectors
From: |
Neil Jerram |
Subject: |
Re: make-shared-array and bitvectors |
Date: |
Fri, 17 Nov 2006 14:58:27 +0000 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
"Ryan Moore" <address@hidden> writes:
> Making a shared array out of a bit vector does not result in a bit
> vector being returned when the shared array does not have as many
> elements as the original:
>
> (define somebits (make-bitvector 8 #f))
> (define subbits (make-shared-array somebits (lambda (dim) (list dim))
> 4))
> (define allsubbits (make-shared-array somebits (lambda (dim) (list dim))
> 8))
>
> (bitvector? somebits) => #t
> (bitvector? subbits) => #f
> (bitvector? allsubbits) => #t
And in fact:
(eq? somebits allsubbits) => #t
Because of this special case code in scm_make_shared_array:
if (1 == SCM_I_ARRAY_NDIM (ra) && 0 == SCM_I_ARRAY_BASE (ra))
{
SCM v = SCM_I_ARRAY_V (ra);
size_t length = scm_c_generalized_vector_length (v);
if (1 == s->inc && 0 == s->lbnd && length == 1 + s->ubnd)
return v;
...
}
So allsubbits is really just another reference to somebits, not a
shared array at all.
> The 1.8 manual states: "Bit vectors are are also generalized vectors,
> See Generalized Vectors, and can thus be used with the array procedures,
> See Arrays" but as we can see, array procedures do not work as expected
> on bitvectors. If this is expected behavior, I feel it should be
> clarified. I would think that making a shared array out of a bitvector
> would result in a bitvector after all...
According to the current implementation, it's wrong (in general) to
expect (make-shared-array <bitvector> ...) to satisfy the bitvector?
predicate.
Is this a problem for you in practice?
Regards,
Neil