guile-devel
[Top][All Lists]
Advanced

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

make-shared-array


From: Daniel Llorens del Río
Subject: make-shared-array
Date: Thu, 28 Sep 2006 11:04:28 +0200


Hello,

I've found a typo in the documentation and a bug in libguile/unif.c/ scm_make_shared_array().

The last example says:

(make-shared-array #1(a b c d e f g h i j k l)
                   (lambda (i) (* i 3))
                   4)

The 2nd argument should be (lambda (i) (list (* i 3))).

Anyway this fails with an 'out of bounds' error in guile 1.8.0. The reason is that SCM_I_ARRAYP(vector) is false (*) and SCM_I_ARRAY_BASE (vector) gives garbage, but scm_make_shared_array() uses it anyway.

Here is a patch against guile-1.8.0/libguile/unif.c.

--------------------------
873c873,874
<   if (SCM_I_ARRAYP (oldra))
---
>   const int oldra_is_array = SCM_I_ARRAYP(oldra);
>   if (oldra_is_array)
912c913
< SCM_I_ARRAY_BASE (ra) = new_min = new_max = i + SCM_I_ARRAY_BASE (oldra);
---
> SCM_I_ARRAY_BASE (ra) = new_min = new_max = i + (oldra_is_array ? SCM_I_ARRAY_BASE (oldra) : 0);
--------------------------

(*) but they give #t for array?.

Regards,
        Daniel.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]