Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!gatech2!usenet.eel.ufl.edu!newsfeed.internetmci.com!EU.net!Germany.EU.net!news.maz.net!news.ppp.net!news.Hanse.DE!wavehh.hanse.de!cracauer
From: cracauer@wavehh.hanse.de (Martin Cracauer)
Subject: Re: Read/write binary files in Scheme? In Scsh?
Message-ID: <1995Nov28.120313.13801@wavehh.hanse.de>
Organization: BSD User Group Hamburg
References: <48jctp$iil@news.connectnet.com> <1995Nov20.141202.4705@wavehh.hanse.de> <BDC.95Nov20151853@rolex.mit.edu> <SCHWARTZ.95Nov21140925@galapagos.cse.psu.edu> <dmb-2511950203560001@pm-4-19.connectnet.com>
Date: Tue, 28 Nov 95 12:03:13 GMT
Lines: 39

dmb@connectnet.com (David Brumley) writes:

>In article <SCHWARTZ.95Nov21140925@galapagos.cse.psu.edu>,
>schwartz@galapagos.cse.psu.edu (Scott Schwartz) wrote:

>> bdc@rolex.mit.edu (Brian D. Carlstrom) writes:
>> | i find in these cases that "the memory as string" style works well. i
>> | build by 8 bit data in a string and then send that down the pipe
>> 
>> The problem there is that a string isn't necessarily the same notion
>> as an array-of-bytes.  You might want to represent characters as 16
>> bit (unicode) runes, and pack and unpack them into arrays of multibyte
>> (utf-8) sequences as needed.

>So it would seem that portable binary file I/O is impossible in Scheme.  

>Everyone here probably already knows this, but Common Lisp provides binary
>streams with read-byte and write-byte functions.  Although I've ignored
>Common Lisp because I thought it was bloated and antiquated, I'm giving it
>a second look since it provides what I consider essential functionality
>for graphics software (portable binary file I/O).

ANSI CL even provides read-sequence and write-sequence, which is
probably what soemone who constructs a string with the intention to
write it out as binary data wants. No to speak of performance
improvements, since ...-sequence is not longer limited to single bytes
on transfers.

This is related to my original point in this debate. To make heavy use
of binary I/O, you're probably better of implementing something like
read/write-sequence for at least one byte-oriented sequence. Using a
FFI.

Martin
-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Martin Cracauer <cracauer@wavehh.hanse.de>  - BSD User Group Hamburg, Germany 
"As far as I'm concerned,  if something is so complicated that you can't ex-"
"plain it in 10 seconds, then it's probably not worth knowing anyway"- Calvin
