Subject: Re: Lisp io performance.
From: Erik Naggum <>
Date: 1999/01/19
Newsgroups: comp.lang.lisp
Message-ID: <>

* Barry Margolin <>
| BTW, stylistic note: any time a number outside the range -1:1, e.g. 8192,
| appears multiple times in a piece of code, it's probably a candidate for
| a DEFCONSTANT.  In the case of this function, DEFPARAMETER might be more
| appropriate, so you can experiment with different size buffers simply by
| changing the value (for those of you who have wondered, this is where
| DEFPARAMETER gets its name).

  in this case, I think it's also worth pointing out that the size of the
  string is still available.  (length buffer) will yield 8192.

  FWIW, here's my cut at it:

(defconstant disk-block-size 8192)

(defun copy-file (from to)
  (with-open-file (in from :direction :input)
    (with-open-file (out to :direction :output :if-exists :supersde)
      (let ((buffer (make-array disk-block-size
		      :element-type (stream-element-type in))))
	(loop for read = (read-sequence buffer in) until (zerop read) do
	      (write-sequence buffer out :end read))))))

  SIGTHTBABW: a signal sent from Unix to its programmers at random
  intervals to make them remember that There Has To Be A Better Way.