Re: Strange behaviour of *standard-output* in sbcl
- From: tar@xxxxxxxxxxxxx (Thomas A. Russ)
- Date: 30 Jul 2008 11:43:31 -0700
pjb@xxxxxxxxxxxxxxxxx (Pascal J. Bourguignon) writes:
Haiwei <highfly22@xxxxxxxxx> writes:....
Hi,
When executing following expression, the output file only has part of
contents. The size of this file is 12281.
(let ((*standard-output* (open "/home/haiwei/tmp/tmplog"
:if-exists :rename-and-delete
:if-does-not-exist :create
:direction :output)))
(judydl-enumerate root je))
You don't close the file, so some bytes remain in the buffer.
Also, it is often useful to include FORCE-OUTPUT at places where
interactive streams, in particular, are used.
Use rather WITH-OPEN-FILE,...
And to amplify Pascal's advice, I will point out that you can use
WITH-OPEN-FILE to bind *standard-output* as well:
(with-open-file (*standard-output* "/home/haiwei/tmp/tmplog"
:if-exists :rename-and-delete
:if-does-not-exist :create
:direction :output)
(judydl-enumerate root je))
--
Thomas A. Russ, USC/Information Sciences Institute
.
- References:
- Strange behaviour of *standard-output* in sbcl
- From: Haiwei
- Re: Strange behaviour of *standard-output* in sbcl
- From: Pascal J. Bourguignon
- Strange behaviour of *standard-output* in sbcl
- Prev by Date: Re: Turn an ordinary function into a generic function
- Next by Date: Re: Lisp Machine keyboard usage
- Previous by thread: Re: Strange behaviour of *standard-output* in sbcl
- Next by thread: Lisp based DSL for bio on Ars Technica
- Index(es):