As akkartik said, the problem is that "write" wraps strings in double-quotes. Oddly enough, Arc doesn't provide dispfile, which would do what you want. There's two ways to implement dispfile: the simple way...
(def dispfile (val file)
(w/outfile f file
(disp val f))
val)
...or by copy+pasting writefile and changing it to use disp:
(def dispfile (val file)
(let tmpfile (+ file ".tmp")
(w/outfile o tmpfile (disp val o))
(mvfile tmpfile file))
val)
I personally would go for the simple way. I dislike the way Arc handles temporary files, so if I wanted to use temp files + move, I'd end up changing the entire temporary file implementation...
For comparison, I think this is the shortest way to do this without introducing a new name:
(tofile "tmpfile" (disp "this is some text"))
---
How would you better implement writefile? I think the goal is to avoid corrupting a file that gets repeatedly updated. If the disk fills up, for example, you might end up losing the previous version and unable to fully write the new version.
What don't you like about the way Arc handles temporary files? Is that you can't have another file named that? Arc could use `(file-gensym)` instead, if that was a thing.
Thanks for the tip! I had no idea there could be a better way. Now I find that my use of $RANDOM in shell scripts should be replaced with calls to mktemp as well.
Now tofile does the 'write to tmp file and move' dance. writefile is implemented in terms of tofile. Finally, the tmp file is more randomly chosen, so it should be thread-safe.