Edit: I changed the title and (slightly) the wording of this question in order to make it more easily answerable.
If I evaluate this in Mathematica 9:
SetAttributes[foo, HoldFirst]
foo[x_] :=
(T`var := x;
DeleteFile["thisisatest"];
Save["thisisatest", "T`"]
)
foo[$ProcessID]
The resulting saved file looks like this:
T`var := $ProcessID
$ProcessID = 6903
If I evaluate Get["thisisatest"], mathematica complains that I shouldn't be setting the value of special symbol $ProcessID. If I change Save to DumpSave and try again, Get no longer triggers the complaint. Examination of the saved file in a text editor shows no evidence of a stored value for $ProcessID, though it's a little hard to tell.
The behavior I want is that of DumpSave, but platform independent. The documentation seems to suggest that these two functions would be interchangeable, except that Save will append to an existing file. What are the known differences between the two functions in practice, and how does one account for them?
Saveproduces a file that, when evaluated, restores the values of symbols inT`.DumpSavecreates a file that, when loaded, restores the in-memory state of whatever you saved fromT`. It might not even save$ProcessID. The difference is evaluating something that recreates the state, or just loading the state directly. This is just a wild guess. I don't understand the internals. But I'd say not a bug. – Szabolcs Feb 10 '13 at 01:39Saveconverting delayedUpValues- based definitions to immediate ones (don't remember which one was the culprit -SaveorGet), in this answer. Did not really find time to get deeper into it, but have a look atretrieveMainListfunction there for a work-around and some comments I made about it. – Leonid Shifrin Feb 10 '13 at 01:41SaveandDumpSave?" Barring an official response from Wolfram by somebody who has looked at the relevant code, the question in its original form was difficult to answer conclusively. Barring further activity (I'd still like to know if anyone has further observations about the differences between the two functions), I'll accept @LeonidShifrin's comment as an answer via a community wiki post. – Tobias Hagge Feb 10 '13 at 19:48