Re: Strange behaviour of *standard-output* in sbcl



On Jul 30, 1:39 pm, Richard M Kreuter <kreu...@xxxxxxxxx> wrote:
Joshua Taylor <joshuaaa...@xxxxxxxxx> writes:
The Hyperspec says about WITH-OPEN-FILE, "with-open-file uses open
to create a file stream to file named by filespec. Filespec is the
name of the file to be opened. Options are used as keyword arguments
to open." From an issue write (about dynamic extent, not directly
relevant here), "[WITH-OPEN-FILE] probably should inherit whatever
restrictions are placed on WITH-OPEN-STREAM, so you can implement it
that way."

This suggests that WITH-OPEN-FILE could be implemented as

(defmacro with-open-file2 ((var filename &rest options) &body body)
  `(with-open-stream (,var (open ,filename ,@options))
     ,@body))

Not necessarily.  WITH-OPEN-FILE has an extra requirement:

|  If a new output file is being written, and control leaves
|  abnormally, the file is aborted and the file system is left, so far
|  as possible, as if the file had never been opened.

I don't see anything in WITH-OPEN-STREAM to suggest that it's supposed
to do anything interesting in case of abnormal transfer out of the
body.

Ah, good catch. So we have at least two cases for WITH-OPEN-STREAM,
one of which is when the stream isn't one easily produced by OPEN, and
another which is when the stream can be created by OPEN, but if
something happens in the middle, the file should still be present
afterward. Have we got any more cases?

//JT
.



Relevant Pages

  • Re: Strange behaviour of *standard-output* in sbcl
    ...   (judydl-enumerate root je)) ... I got all the output after closed the stream. ... But when to use WITH-OPEN-STREAM? ... create a file stream to file named by filespec. ...
    (comp.lang.lisp)
  • Re: C# Vs VB.NET
    ... > because it was written in one language and then simply syntax-translated to ... Translation can usually be done line by line, keyword by ... > With s As Stream = ... ... Stream temp = null; ...
    (microsoft.public.dotnet.framework.clr)
  • Re: C# Vs VB.NET
    ... > If you're opening streams in VB.NET and not calling Dispose or Close in ... IDisposables in the framework go the extra length and make sure everything ... Translation can usually be done line by line, keyword by ... >> With s As Stream = ... ...
    (microsoft.public.dotnet.framework.clr)
  • Using Keyword Dispose and GC
    ... Our .Net team have been pondering about using keyword. ... We are using streams FileStream and BufferedStream. ... If file stream is grabage collected, there is no need to use Using ...
    (microsoft.public.dotnet.csharp.general)
  • Using Keyword Dispose and GC
    ... Our .Net team have been pondering about using keyword. ... We are using streams FileStream and BufferedStream. ... If file stream is grabage collected, there is no need to use Using ...
    (microsoft.public.dotnet.framework.performance)