Pascal J. Bourguignon <pjb@informatimago.com> wrote:
+---------------
| Spiros Bousbouras <spibou@gmail.com> writes:
| > I was thinking perhaps a situation where you want to
| > modify a file in place. So you do
| > (open filespec :direction :input) and then
| > (open filespec :direction :output :if-exists :supersede)
| > You read from the first stream , do the modifications you want
| > and write to the second stream. When you're finished you close
| > the first stream and then the second. Would this work ?
|
| You cannot open the same file twice at the same time.
+---------------
I can't find any restriction against this in the CLHS "Function OPEN"
page. And, indeed, neither CMUCL nor CLISP seems to complain:
cmu> (with-open-file (s0 "foo1")
(with-open-file (s1 "foo1")
(with-open-file (s2 "foo1")
(mapcar #'read-line (list s0 s1 s2)))))
("Hello, there!" "Hello, there!" "Hello, there!")
cmu>
[1]> (with-open-file (s0 "foo1")
(with-open-file (s1 "foo1")
(with-open-file (s2 "foo1")
(mapcar #'read-line (list s0 s1 s2)))))
("Hello, there!" "Hello, there!" "Hello, there!")
[2]>
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607