Re: [Scheme-reports] Blobs vs. byte vectors Andy Wingo 22 May 2011 19:10 UTC

Hello,

On Sun 22 May 2011 19:43, John Cowan <cowan@mercury.ccil.org> writes:

> My original view of blobs was as something that didn't have a native
> structure, but was just raw binary data.  That's why I proposed the
> name "blob" rather than "byte/octet vector", which would imply a native
> structure of octets.  In my view, blobs could be seen as octets, but
> equally well as 32-bit words in network (big-endian) order, or double
> complex numbers, or UTF-8 strings.  All these interpretations are equal
> in BlobAPI.

This is all fine to me.  For example this is what Guile does: you can
access bytevectors with the SRFI-4 accessors.  There is a type bit
saying what the default interpretation should be, which is useful for
printing, for example.  But you can do (bytevector-u16-ref (u32vector 0)
2 (endianness little)), and you get 0.

> For blobs in full generality, though, blob-map would make no sense
> because there was no unique element type for it to map over.

A fair point.  However I still fail to get the difference relative to
R6RS bytevectors; e.g. you don't have bytevector-ref, it's
bytevector-u8-ref.  So you could have bytevector-u8-map, the same as
blob-u8-map -- not that I think that's a useful operation of course ;-).

> So somehow the mental model issue has to be resolved, after which these
> details will just fall out naturally.  If blobs are really u8 vectors
> and everything else is just an overlay, then blob-map, blob-for-each,
> etc. make sense.  If all views of blobs are cognitively equal (which
> is how I really think), then they don't, and the restriction to a u8
> setter/getter is just to keep WG1 small.

It is a leaky abstraction, I think.  For any unit which is not one byte
in length, you always have to be concerned about the size of the total
array.  There's no way to treat (make-blob 5) as an array of u32 values.
How would a blob not be interpretable an array of bytes?  It is implicit
in the type of `make-blob' that it's a bytes thing.

Andy
--
http://wingolog.org/

_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports