unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Daniel Llorens <daniel.llorens@bluewin.ch>
To: Daniel Hartwig <mandyke@gmail.com>
Cc: guile-devel <guile-devel@gnu.org>
Subject: Re: vector types poll
Date: Tue, 16 Apr 2013 02:16:19 +0200	[thread overview]
Message-ID: <D82A08B3-866C-405A-93AB-83EF66104325@bluewin.ch> (raw)
In-Reply-To: <CAN3veRfvSkJ3-QPCeoAb=hwJOTGPz8SaxEbWpbatnPoqvS3t4w@mail.gmail.com>


On Apr 16, 2013, at 00:47, Daniel Hartwig wrote:

> Is column [4] intentionally missing from all but the first set?  I was
> expecting it for atleast s8vector.

I wasn't sure, but it makes sense. Then the same for bitvector, I think. What about bytevector? Should it remain a special 'raw' type? But the standards treat it like vector, so maybe it should follow the same logic. And string?

--

(import (rnrs bytevectors))
(define (every-two a) (make-shared-array a (lambda (i) (list (+ 1 (* 2 i)))) 2))
(define (offset1 a) (make-shared-array a (lambda (i) (list (1- i))) `(1 ,(array-length a))))

; [1] http://lists.gnu.org/archive/html/guile-devel/2013-04/msg00158.html
; [2] stable-2.0 [e006d87]
; [3] all array-type objects are actually arrays and support offsets, strides, etc.
; [4] D. Hartwig and I may agree on this, follows functional definition of r5rs vectors.

; -------------------------- [1] ------------ [2] --------- [3] ------ [4]

(define a #(1 2 3 4))
(define b (every-two a))
(define c (offset1 a))
(vector? a)                  ; #t             #t            #t         #t
(vector? b)                  ; #f             #f            #t         #t
(vector? c)                  ; #f             #f            #t         #f
(vector-ref a 1)             ; 2              2             2          2
(vector-ref b 1)             ; bad type       4             4          4
(vector-ref c 1)             ; bad type       2             1          bad type
(array-ref c 1)              ; 1

(define a "1234")
(define b (every-two a))
(define c (offset1 a))
(string? a)                  ; #t             #t            #t
(string? b)                  ; #f             #f            #t
(string? c)                  ; #f             #f            #t
(string-ref a 1)             ; #\2            #\2           #\2
(string-ref b 1)             ; bad type       bad type      #\4
(string-ref c 1)             ; bad type       bad type      #\1
(array-ref c 1)              ; #\1

(define a #s8(1 2 3 4))
(define b (every-two a))
(define c (offset1 a))
(s8vector? a)                ; #t             #t            #t         #t
(s8vector? b)                ; #f             #t            #t         #t
(s8vector? c)                ; #f             #t            #t         #f
(s8vector-ref a 1)           ; 2              2             2          2
(s8vector-ref b 1)           ; bad type       bad type      4          4
(s8vector-ref c 1)           ; bad type       bad type      1          bad type
(array-ref c 1)              ; 1

(define a #s8(1 2 3 4))
(define b (every-two a))
(define c (offset1 a))
(bytevector? a)              ; #t             #t            #t
(bytevector? b)              ; #f             #f            #t
(bytevector? c)              ; #f             #f            #t
(bytevector-s8-ref a 1)      ; 2              #\2           2
(bytevector-s8-ref b 1)      ; bad type       bad type      4
(bytevector-s8-ref c 1)      ; bad type       bad type      1
(array-ref c 1)              ; 1

(define a (list->bitvector '(#t #f #t #t))) ; ad syntax for vectors is broken
(define b (every-two a))
(define c (offset1 a))
(bitvector? a)               ; #t             #t            #t         #t
(bitvector? b)               ; #f             #f            #t         #t
(bitvector? c)               ; #f             #f            #t         #f
(bitvector-ref a 1)          ; #f             #f            #f         #f
(bitvector-ref b 1)          ; #t [bad type]  #t            #t         #t
(bitvector-ref c 1)          ; #f [bad type]  #f            #t         bad type
(array-ref c 1)              ; #t







  reply	other threads:[~2013-04-16  0:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1288755.1365813667.854.guile-devel@gnu.org>
2013-04-15 11:29 ` vectors are something else Daniel Llorens
2013-04-15 12:28   ` Daniel Hartwig
2013-04-15 14:08     ` Daniel Llorens
2013-04-15 14:17       ` Daniel Hartwig
2013-04-15 14:10     ` vector types poll Daniel Llorens
2013-04-15 22:47       ` Daniel Hartwig
2013-04-16  0:16         ` Daniel Llorens [this message]
2013-04-16  2:00   ` vectors are something else Mark H Weaver
2013-04-16  4:10     ` Daniel Llorens
2013-04-16  6:19       ` Mark H Weaver
2013-04-16  8:31         ` Daniel Llorens
2013-04-17 15:29     ` Mutable top-level bindings (was: vectors are something else) Chris K. Jester-Young
2013-04-17 17:53       ` Mutable top-level bindings Mark H Weaver
2013-04-17 20:25       ` Ian Price
2013-04-20 14:00       ` Ludovic Courtès

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=D82A08B3-866C-405A-93AB-83EF66104325@bluewin.ch \
    --to=daniel.llorens@bluewin.ch \
    --cc=guile-devel@gnu.org \
    --cc=mandyke@gmail.com \
    /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).