unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Neil Jerram <neil@ossau.uklinux.net>
Cc: bug-guile@gnu.org
Subject: Re: make-shared-array and bitvectors
Date: Fri, 17 Nov 2006 14:58:27 +0000	[thread overview]
Message-ID: <87odr6qfvw.fsf@ossau.uklinux.net> (raw)
In-Reply-To: <4548CF2B020000FC0000425F@WC-MESSAGE.westminster.edu> (Ryan Moore's message of "Wed, 01 Nov 2006 16:45:31 -0500")

"Ryan Moore" <moorerw@westminster.edu> 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



_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile


      reply	other threads:[~2006-11-17 14:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-01 21:45 make-shared-array and bitvectors Ryan Moore
2006-11-17 14:58 ` Neil Jerram [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87odr6qfvw.fsf@ossau.uklinux.net \
    --to=neil@ossau.uklinux.net \
    --cc=bug-guile@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).