[plt-scheme] bytes vs u8vector

From: Eli Barzilay (eli at barzilay.org)
Date: Sat Jan 28 11:47:17 EST 2006

On Jan 28, Lauri Alanko wrote:
> On Sat, Jan 28, 2006 at 11:04:25AM -0500, Eli Barzilay wrote:
> > A few issues:
> > 
> > 1. The same implementation is used for all srfi-4 vectors.  You're
> >    talking about an exception for one case.
> Right, it would certainly require some work, I don't doubt
> that. Then again, u8vectors are arguably conceptually more primitive
> anyway, and they even have a dedicated SRFI (66). In SRFI-land the
> basic type for binary data is u8vector, whereas in mzscheme it is
> byte-string, and this a troublesome incompatibility.

Byte strings are neither more nor less primitive than u8vectors.  They
are different facilities.

> > 2. Making that one case use byte strings is not possible, since a byte
> >    string always has a terminating \nul character.
> I must be missing something. Yes, byte strings are allocated one
> longer than their nominal length and there's a zero at the end, but
> I've always thought that this is just for compatibility with
> standard C functions (even though it's only useful when there are no
> zeros elsewhere in the byte string). One isn't really supposed to
> touch the terminator anyway, so I don't see how its presence
> matters.

The problem is not when a byte string is allocated, it's when a
foreign function returns a "u8vector" -- it cannot be made into a byte
string, so there should be two types at the low-level implementation.

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.