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

Re: Revision of SRFI 66 available

This page is part of the web mail archives of SRFI 66 from before July 7th, 2015. The new archives for SRFI 66 contain all messages, not just those from before July 7th, 2015.




Hello Mike,

1. Poll: I do like the names. You might consider shortening "byte-vector"
to "bytes" (e.g. make-bytes, bytes, bytes-length, etc.); but that only makes
sense if you expect applications that really deal with byte vectors a lot (I/O
might be one of them.) Not sure I would do it myself; byte-vector is
unbeatably clear to anyone.

2. byte-vector=?: Would you consider replacing byte-vector=? by
byte-vector-compare---returning -1, 0 or 1 in the sense of SRFI-67
according to "vector-ordering" (i.e. by length, then lex.)?
    You can immediately store byte-vectors in efficient associative
data structures (heaps), and performance-wise it will be a nuissance
if anyone needs to implement it in Scheme later.

3. byte-vector-copy!: Should be required to work even if if source
and dest overlap in memory. (See example below.)

4. Notation "range [0, 255]" and "indices [source-start, source-start + n)":
How about "{0, ..., 255}" and "{source-start, ..., source-start + n - 1}"?

5. Typo: "Analogous to vector-ref" -> "Analogous to vector-set!".

Sebastian

--- code dump ---

; corrected copy!

(define (byte-vector-copy! source source-start target target-start count)
  (if (>= source-start target-start)
      (do ((i 0 (+ i 1))) ((= i count))
        (byte-vector-set! target
                          (+ target-start i)
                          (byte-vector-ref source (+ source-start i))))
      (do ((i (- count 1) (- i 1))) ((= i -1))
        (byte-vector-set! target
                          (+ target-start i)
                          (byte-vector-ref source (+ source-start i))))))

; try:
;  (let ((v (byte-vector 0 1 2)))
;    (byte-vector-copy! v 0 v 1 2)
;    (byte-vector-ref v 2)) ; => correct: 1, wrong: 0

; compare (without SRFI-67):

(define (byte-vector-compare byte-vector-1 byte-vector-2)
  (let ((length-1 (byte-vector-length byte-vector-1))
        (length-2 (byte-vector-length byte-vector-2)))
    (cond
      ((< length-1 length-2) -1)
      ((> length-1 length-2)  1)
      (else
       (let loop ((i 0))
         (if (= i length-1)
             0
             (let ((elt-1 (byte-vector-ref byte-vector-1 i))
                   (elt-2 (byte-vector-ref byte-vector-2 i)))
               (cond ((< elt-1 elt-2) -1)
                     ((> elt-1 elt-2)  1)
                     (else (loop (+ i 1)))))))))))

; with SRFI-67 ;-)

(define (byte-vector-compare byte-vector-1 byte-vector-2)
  (compare-vector compare-integer
                  byte-vector-1
                  byte-vector-2
                  byte-vector-length
                  byte-vector-ref))

----
Dr. Sebastian Egner
Senior Scientist Channel Coding & Modulation
Philips Research Laboratories
Prof. Holstlaan 4 (WDC 1-051, 1st floor, room 51)
5656 AA Eindhoven
The Netherlands
tel:       +31 40 27-43166   *** SINCE 10-Feb-2005 ***
fax:      +31 40 27-44004
email: sebastian.egner@xxxxxxxxxxx








srfi-66-request@xxxxxxxxxxxxxxxxx

18-04-2005 18:07

       
        To:        srfi-66@xxxxxxxxxxxxxxxxx
        cc:        (bcc: Sebastian Egner/EHV/RESEARCH/PHILIPS)
        Subject:        Revision of SRFI 66 available

        Classification:        





A revision of SRFI 66 is available at the usual place:

http://srfi.schemers.org/srfi-66/

It fixes a few typos and adds several procedures, BYTE-VECTOR=?,
BYTE-VECTOR-COPY! and BYTE-VECTOR-COPY, all distilled from the
comments on the mailing list.  (Many thanks for those comments!)

I haven't done anything yet wrt. the naming issue---that's still
pending.  I'd like to hold a little poll.  For that, it'd be helpful
if the camp in favor of "u8vector" could suggest names for what's
currently READ-BYTE, READ-BYTES, and READ-BYTES-N in SRFI 68.

--
Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla