[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: make-vector/vector-length disagree for large vectors.
From: |
Dirk Herrmann |
Subject: |
Re: make-vector/vector-length disagree for large vectors. |
Date: |
Wed, 7 Feb 2001 22:41:59 +0100 (MET) |
On 7 Feb 2001, Rob Browning wrote:
>
> guile> (define xxx (make-vector 1000000))
> guile> (vector-length xxx)
> 1000000
> guile> (define xxx (make-vector 100000000))
> guile> (vector-length xxx)
> 16113920
> guile> (version)
> "1.4"
In the current implementation, guile's vectors have a maximum length of
2^24 elements. It is not difficult to change: Instead of a single cell,
vectors could be represented using a double cell, which would allow for
2^32 or even 2^64 vector elements. But, up to now obviously nobody
thought that this would be necessary.
It is a bug, though, that make-vector does not complain if the given
argument is too big. The only thing that is actually checked is, whether
the given size is a fixnum. If it is a bignum, you get a "Wrong type
argument" error message, which is also strange:
Wrong type argument in position 1: 536870912
:-)
The bug with the missing boundary checking is easy to fix. Whether
vectors should be changed to allow for more than 2^24 elements is up to
the maintainers. If the maintainers would decide that way, one could
think of unifying all the different vector types within guile: uniform
vectors, weak and non weak object vectors.
Best regards,
Dirk Herrmann