bug-guile
[Top][All Lists]
Advanced

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

Re: Weak Vectors Patch


From: Andy Wingo
Subject: Re: Weak Vectors Patch
Date: Sun, 18 Apr 2010 13:48:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux)

Hi,

On Sat 17 Apr 2010 22:48, address@hidden (Ludovic Courtès) writes:

> Clinton Ebadi <address@hidden> writes:
>
>> I talked to wingo, and he suggested that (equal? WEAK-VECTOR VECTOR) =>
>> #f;
>
> Hmm what’s the motivation?  It seems more intuitive to me to have, e.g.,
>
>   (equal? (make-vector 3 4) (make-weak-vector 3 4))
>   => #t

Because these have different tc7's, but they were arrays, this
comparison happened via the array handle mechanism; but the array handle
implementation wasn't quite right. So perhaps the proper fix is to keep
weak vectors as being arrays, so they can be equal? to vectors, but fix
up their implementation, to something like this:

static SCM
weak_vector_handle_ref (scm_t_array_handle *h, size_t idx)
{
  return scm_c_vector_ref (h->array, idx);
}

static void
weak_vector_handle_set (scm_t_array_handle *h, size_t idx, SCM val)
{
  scm_c_vector_set_x (h->array, idx, val);
}

static void
weak_vector_get_handle (SCM v, scm_t_array_handle *h)
{
  h->array = v;
  h->ndims = 1;
  h->dims = &h->dim0;
  h->dim0.lbnd = 0;
  h->dim0.ubnd = scm_c_vector_length (v) - 1;
  h->dim0.inc = 1;
  h->element_type = SCM_ARRAY_ELEMENT_TYPE_SCM;
  h->elements = h->writable_elements = NULL; /* disallow direct access */
}

SCM_ARRAY_IMPLEMENTATION (scm_tc7_wvect, 0x7f,
                          weak_vector_handle_ref, weak_vector_handle_set,
                          weak_vector_get_handle)

Clinton can you try this one?

Andy
-- 
http://wingolog.org/




reply via email to

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