[plt-scheme] reading a whole file

From: Thomas Chust (chust at web.de)
Date: Mon Nov 10 13:56:16 EST 2008

Ben Goetter schrieb:
> Thomas Chust wrote:
>> what about adding support for memory mapping to PLT Scheme? This would
>> allow you to turn a whole file into a mutable or immutable byte string
> Only helpful for byte files, or for those rare text files whose encoding
> matches that of PLT Scheme's UCS-4 strings. [...]


if a file contains something else than binary data or text that is
encoded in UCS-4, its contents have to be converted to another
representation in memory, no matter whether it's mapped or read, that's

If you don't read all the input but map the file with the initial data
representation, you save a lot of memory, though, because you only need
to allocate the target representation.

I also think that compared to some of the other suggested solutions it
would be very concise and elegant to type something like this:

  (bytes->string/utf-8 (memory-map "some/file"))

So I disagree that my proposal would not be useful for such cases.


Posted on the users mailing list.