[racket] open-output-file #:exist
Does anyone know a good reference to cite for this information? Like
the details of TCP, I think this is something better explained by an
external reference than in the Racket reference manual.
Meanwhile, I'll look into smoothing the path from functions like
`with-output-to-file' to information about the `exists' values.
At Wed, 24 Aug 2011 17:23:52 +0200, Stephan Houben wrote:
> Hi Marijn,
>
> At least on Unix/Linux, a file (inode) has some distinct identity
> apart from its content.
>
> If a file is truncated, this is observed by all processes which have the file
> open. In addition, all hard-links to the file are also truncated (since
> these are just references to the same inode).
>
> If a file is replaced, the old inode is unaffected: processes which
> had the file open continue to see the old data, other hard links
> keep referring to the old file.
>
> If you don't care about these subtleties you can use truncate/replace.
>
> must-truncate is, I think, mostly useful if the file is to be used
> for some form of inter-process communication. must-replace doesn't seem
> useful in any way to me and moreover cannot be implemented reliably
> without introducing a race condition between checking for existence of
> the file and overwriting it with a new one.
>
> Stephan
>
> On 08/24/2011 03:01 PM, Marijn wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Hi,
> >
> > In the reference in section 12.1.5 File Ports[1], open-output-file is
> > defined as having an optional keyword argument #:exist which can have
> > one of 8 different values. The same options are used for a number of
> > wrapper functions, among which with-output-to-file[2].
> > If you go to [2] you need to follow 3 internal links to similar
> > functions to get to open-output-file[1] to find out what the different
> > values of the #:exists argument mean. I think it would be good if a link
> > was inserted such that you can go straight there.
> > Unfortunately I find some of the explanations not so clear. I will
> > comment on the explanation of each option in the order they appear in
> > the docs.
> > 1) error: this one is clear
> > 2) replace: how is this different from 3) truncate?
> > 3) truncate: see 2)
> > 4) must-truncate: what about must-replace?
> > 5) truncate/replace: clear if 2) and 3) are clarified
> > 6) update: what is the current read/write position (this is hinted at in
> > 8), but should really be explained fully here) and what happens when you
> > write to the file (does it overwrite, insert, either depending on some
> > other option)?
> > 7) can-update: clear if 6) clarified
> > 8) append: why is it only equivalent to update on Windows?
> >
> > Marijn
> >
> >
> >
> [1]:http://docs.racket-lang.org/reference/file-ports.html?#%28def._%28%28lib._ra
> cket/private/base..rkt%29._open-output-file%29%29
> >
> [2]:http://docs.racket-lang.org/reference/file-ports.html?#%28def._%28%28lib._ra
> cket/private/base..rkt%29._with-output-to-file%29%29
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v2.0.17 (GNU/Linux)
> > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> >
> > iEYEARECAAYFAk5U9jIACgkQp/VmCx0OL2wy8ACbBPOVfHYF53NTCkY/9qXnbeyP
> > AIAAn3J0URrJsIIZZiVIh/EOGqOBBJrX
> > =rLk7
> > -----END PGP SIGNATURE-----
> > _________________________________________________
> > For list-related administrative tasks:
> > http://lists.racket-lang.org/listinfo/users
> >
> _________________________________________________
> For list-related administrative tasks:
> http://lists.racket-lang.org/listinfo/users