[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: with-open-stream and with-open-file
Date: Fri, 16 Oct 87 11:33 EDT
From: David C. Plummer <DCP@QUABBIN.SCRC.Symbolics.COM>
CLtL says that the stream (file) scoped by with-open-stream
(with-open-file) is closed when the form is exited, independent of
exit-reason. I would like people to consider the following allowance:
that if the stream variable is NIL during the close operation, then the
stream (file) is not closed. Thus
(with-open-stream (stream constructor)
(prog1 stream (setq stream nil)))
would evaluate to an open stream.
[More language supporting the above as an idiom.]
Surely I'm misunderstanding you. Why use the above form instead of
simply `constructor'? It must be that you mean to do more stuff before
the prog1, perhaps to "set up" the stream and/or some other structures
concerned with it. The idea would be to have the implicit
unwind-protect around those set-up forms and then be able to leave the
unwind-protect with the stream still open. Have I properly understood
your intent?
If so, then I must say that I would find the form you describe far less
clear than the equivalent explicit unwind-protect. In general, I
dislike forms that pass information to invisible parts by the setting of
a lexical variable. The information path is just too hidden.
Pavel