<?xml version="1.0" encoding="utf-8"?>
<!-- If you are running a bot please visit this policy page outlining rules you must respect. http://www.livejournal.com/bots/ -->
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:lj="http://www.livejournal.com">
  <id>urn:lj:livejournal.com:atom1:prettyclose</id>
  <title>prettyclose</title>
  <subtitle>prettyclose</subtitle>
  <author>
    <name>prettyclose</name>
  </author>
  <link rel="alternate" type="text/html" href="http://prettyclose.livejournal.com/"/>
  <link rel="self" type="text/xml" href="http://prettyclose.livejournal.com/data/atom"/>
  <updated>2007-01-01T18:09:17Z</updated>
  <lj:journal userid="11938574" username="prettyclose" type="personal"/>
  <link rel="service.feed" type="application/x.atom+xml" href="http://prettyclose.livejournal.com/data/atom" title="prettyclose"/>
  <link rel="hub" href="http://pubsubhubbub.appspot.com/"/>
  <entry>
    <id>urn:lj:livejournal.com:atom1:prettyclose:543</id>
    <link rel="alternate" type="text/html" href="http://prettyclose.livejournal.com/543.html"/>
    <link rel="self" type="text/xml" href="http://prettyclose.livejournal.com/data/atom/?itemid=543"/>
    <title>OPEN, CLOSE and :SUPERSEDE</title>
    <published>2007-01-01T18:05:37Z</published>
    <updated>2007-01-01T18:09:17Z</updated>
    <category term="cmucl"/>
    <category term="lisp"/>
    <content type="html">The current implementation of (open ... :if-exists :supersede) in CMUCL (and SBCL) is arguably wrong, especially when considering (close ... :abort t).&lt;br /&gt;&lt;br /&gt;I suggest we rename the file being opened to a temporary file name, generated by appending (symbol-name (gensym "SUPERSEDED-")) to the file-type (to make the risk of collisions smaller; to be a little more certain, PROBE-FILE it, as well).&lt;br /&gt;&lt;br /&gt;Aside from that, what :rename-and-delete currently does is the closest fit that is possible and useful on a regular unix fs, to the best of my knowledge and understanding.&lt;br /&gt;&lt;br /&gt;The current behaviour of :supersede (open and truncate) via O_TRUNC is useful, though, so I suggest an extension with the name :truncate (since there is no other way to do that, with just OPEN and standard args).&lt;br /&gt;&lt;br /&gt;This is how some different options to OPEN currently work in CMUCL (and, I think, SBCL, except for versions) for "standard streams" (fd-streams):&lt;br /&gt;&lt;br /&gt;:if-exists -- note that this is only used if :direction is :io or :output, otherwise ignored&lt;br /&gt;&lt;br /&gt;- :error -- Signals an error if the file exists. New, empty file, at position 0.&lt;br /&gt;open() &amp;lt;- O_EXCL&lt;br /&gt;&lt;br /&gt;- :new-version -- If the file exists, use the Emacs version stuff; that is, the newest version is "foo.lisp", the first version is "foo.lisp.~1~", and so on. Find the highest-                  numbered version, and rename the current file to that+1, and create a new file. New, empty file, at position 0.&lt;br /&gt;open() -&amp;gt; O_CREAT&lt;br /&gt;&lt;br /&gt;- :rename -- Rename the current file to "filename.BAK", and create a new file. If (close ... :abort t) is called, undo the renaming. If "filename.BAK" exists, overwrite it.&lt;br /&gt;open() &amp;lt;- O_CREAT&lt;br /&gt;&lt;br /&gt;- :rename-and-delete -- As above, except after a non-abort CLOSE, delete the renamed file. New, empty file, at position 0.&lt;br /&gt;open () &amp;lt;- O_CREAT&lt;br /&gt;&lt;br /&gt;- :overwrite -- Open the current file, at position 0.&lt;br /&gt;No truncation, no open() flags.&lt;br /&gt;&lt;br /&gt;- :append -- Open the current file, at file-position end-of-file.&lt;br /&gt;No truncation, no open() flags.&lt;br /&gt;&lt;br /&gt;- :supersede -- Open the current file, truncated, at position 0. &lt;br /&gt;open() &amp;lt;- O_TRUNC&lt;br /&gt;&lt;br /&gt;- nil -- Return nil. No opening occurs.&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;&lt;br /&gt;Note that this behaviour of :if-exists :supersede, which I consider wrong, appears to be the same in the current versions of CMUCL, SBCL, Allegro CL, LispWorks, CLISP, GCL, and ECL on my machine, 2006-12-30.</content>
  </entry>
</feed>
