[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

:IF-EXISTS :SUPERSEDE vs. :NEWEST



As I understand :IF-EXISTS :SUPERSEDE and :TRUNCATE, these two options should
be identical except with respect to the amount of available storage in the
file system while the file is open, and to what action is taken if writing to
the file is aborted.  But, most importantly, they should be identical with
respect to whether or not a new file is created.  The only reason I would use
:TRUNCATE instead of :SUPERSEDE is if the amount of data being written was a
sizable fraction of the amount of available space in the filesystem.

Currently, in LMFS, (OPEN "a.b.newest" ... :IF-EXISTS :SUPERSEDE) will always
create a new file, but (OPEN "a.b.newest" ... :IF-EXISTS :TRUNCATE) will only
create a new file if no versions of a.b already exist.  Regardless of what is
decided for :SUPERSEDE, I would like to see :TRUNCATE work the same way.  The
current LMFS behavior is asymmetric and difficult to document.

I feel that either of the proposed behaviors for :SUPERSEDE of a newest
version are reasonable.  I can see arguments for either one.  Therefore, which
definition is chosen should depend upon how easy it is to get the other
behavior from the chosen one, and what the implications are for the
implementor.  I can't comment on the latter issue, but here is an example of
the former.

Given the current LMFS definition for :SUPERSEDE, if I want to supersede the
newest version, I must (in Symbolics Release 5.0) do:

(DEFUN OPEN-SUPERSEDE (PATH)
  (IF (NOT (EQ (SEND PATH :VERSION) :NEWEST))
      (OPEN PATH :DIRECTION :OUTPUT :IF-EXISTS :SUPERSEDE)
      (LET ((FILES (CDR (FS:DIRECTORY-LIST (SEND PATH :NEW-VERSION :WILD)
					   :SORTED :FAST))))
	(IF (NULL FILES)
	    (OPEN PATH :DIRECTION :OUTPUT)
	    (OPEN (CAAR (LAST FILES))
		  :DIRECTION :OUTPUT
		  :IF-EXISTS :SUPERSEDE)))))

I believe this is what Scott Fahlman suggested I do.

Given the current LMFS definition for :TRUNCATE, if I do not want to truncate
the newest version, I must do:

(DEFUN OPEN-TRUNCATE (PATH)
  (OPEN PATH 
	:DIRECTION :OUTPUT 
	:IF-EXISTS (IF (EQ (SEND PATH :VERSION) :NEWEST) :TRUNCATE :CREATE)))

In other words, if you know that the version of PATH is :NEWEST, then it is a
simple matter to say :IF-EXISTS :CREATE instead of :IF-EXISTS :SUPERSEDE.  But
if you really do want to supersede the newest version, then you must first
list the directory.

The issue I feel strongly about is that :SUPERSEDE and :TRUNCATE should behave
similarly with respect to file creation.  I think I convinced Bernie that this
isn't hard to do in LMFS.

    Date: Monday, 5 December 1983, 11:25-EST
    From: Bernard S. Greenberg <BSG at SCRC-TENEX>
    Argument #1:
      Imagine a program that took user input for a file name, and wrote
      out to that file.  (Can't argue with that, right?).  Suppose further
      that this program did not like the CL default of :error, and wanted
      you to be able to write out to a.b.3 if that's what you said.
      So it might open its file with :IF-EXISTS :SUPERSEDE.  Well, suppose
      you said a.b.newest to it?  You CERTAINLY don't want it looking up
      what the latest version is and superseding it!  You want it to create
      a new version.

If that is how you wish to define your user-interface, then you should say
:IF-EXISTS :CREATE if the user has specified a pathname with .newest.  One
can imagine a user interface which would supersede the newest version.

    Argument #2:
      Given the primitives available to the file server in versionated
      operating systems, it is impossible to implement this as proposed
      without a window between determining the version number and opening
      it for superseding.

Given what it is that the programmer is trying to do, the window will always
exist.  You are just moving the window into user code, as in the
OPEN-SUPERSEDE function defined above.