From: Daniel Llorens <daniel.llorens@bluewin.ch>
To: guile-devel <guile-devel@gnu.org>
Subject: vector types poll
Date: Mon, 15 Apr 2013 16:10:11 +0200 [thread overview]
Message-ID: <4A332BC6-A1C2-483F-BF6E-2C06D1C8AA68@bluewin.ch> (raw)
In-Reply-To: <CAN3veRdedPZRhmbYeD9FFZiKr4776UAjgD0ukUp-8bmLUx22_A@mail.gmail.com>
Let's please agree on a behavior so we can start closing bugs. These are all the objects accepted by the array interface. I've filled the table with some ready-made choices that I think are at least internally consistent.
; --
(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* arrays and support offsets, strides, etc.
; [4] Common ground btw D. Hartwig and I (?), functionally 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
(s8vector? b) ; #f #t #t
(s8vector? c) ; #f #t #t
(s8vector-ref a 1) ; 2 2 2
(s8vector-ref b 1) ; bad type bad type 4
(s8vector-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))
(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))) ; read syntax for vectors is broken
(define b (every-two a))
(define c (offset1 a))
(bitvector? a) ; #t #t #t
(bitvector? b) ; #f #f #t
(bitvector? c) ; #f #f #t
(bitvector-ref a 1) ; #f #f #f
(bitvector-ref b 1) ; #t [bad type] #t #t
(bitvector-ref c 1) ; #f [bad type] #f #t
(array-ref c 1) ; #t
should be bad type; to be fixed ------^
Regards,
Daniel
next prev parent reply other threads:[~2013-04-15 14:10 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 ` Daniel Llorens [this message]
2013-04-15 22:47 ` vector types poll Daniel Hartwig
2013-04-16 0:16 ` Daniel Llorens
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=4A332BC6-A1C2-483F-BF6E-2C06D1C8AA68@bluewin.ch \
--to=daniel.llorens@bluewin.ch \
--cc=guile-devel@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).