Subject: Re: fast io From: Erik Naggum <erik@naggum.no> Date: 1997/01/20 Newsgroups: comp.lang.lisp Message-ID: <3062778140294367@naggum.no> * Bjorn Borud | I am looking for ways to read and write blocks of data fast in Scheme or | Common Lisp, but I can only find per-character IO-routines or, at best, | per-line. what I would like to do is to read entire files using read() | or equivalent -- or perhaps something like mmap(). ANSI Common Lisp has `read-sequence' and `write-sequence'. I have answered the exact same question from somebody else from GUARDIAN.NO in no.lisp, and I don't feel like translating. however, here's the code I suggested: (let ((block (make-array '(8192) :element-type 'character))) (with-open-file (stream <file> :element-type 'character) ... (read-sequence block stream) ...)) in Franz, Inc's, Allegro Common Lisp 4.3 for Unix, this uses the `read' system call directly from file descriptor to the block, at least as far as I can determine, and it also returns the same value as the `read' system call returned. in Allegro, you can also give an array static allocation, so you are guaranteed that it won't be moved during garbage collection I have not seen anything that supports `mmap', and I can't offhand see how I could do it work since `mmap' interacts with memory in weird ways and I don't know how or if that would upset Allegro. it might be a trivial question of using the Foreign Function Interface extension to Common Lisp. I don't have time to investigate that right now. #\Erik -- 1,3,7-trimethylxanthine -- a basic ingredient in quality software.