(let((i(make-stream 0 :element-type'(mod 256)))(o(make-stream 1
:direction :output :element-type'(mod
These are the shortest programs that I can make, yet none are under 100 bytes.
The main problem is that
*standard-output* are character streams, not byte streams. A simple
(loop(write-char(read-char)) would copy the characters but would fail to preserve bytes that did not form valid characters. Now my Common Lisp implementations want to use UTF-8 (perhaps because my locale is UTF-8), but I want to copy binary files that my not be valid UTF-8. Therefore I must copy bytes, not characters.
In ECL and SBCL, standard input and output are bivalent for both bytes and characters. I may use
write-byte, but those functions lack default streams, so I must pass
*standard-output* as arguments.
CLISP insists that
*standard-output* transport only characters. The way around this is to call
ext:make-stream on file descriptor 0 (standard input) and file descriptor 1 (standard output) to make binary streams.
All three programs loop byte by byte. This is a slow way to copy bytes. A faster way would use a vector of 16384 bytes with
write-sequence, but the program would be longer.