# What are the known differences between Save and DumpSave, and how to account for them?

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_] :=
(Tvar := x;
DeleteFile["thisisatest"];
Save["thisisatest", "T"]
)

foo[$ProcessID]  The resulting saved file looks like this: Tvar :=$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? - Just a guess: Save produces a file that, when evaluated, restores the values of symbols in T . DumpSave creates a file that, when loaded, restores the in-memory state of whatever you saved from T . 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 1:39
I have encountered similar problem with Save converting delayed UpValues- based definitions to immediate ones (don't remember which one was the culprit - Save or Get), in this answer. Did not really find time to get deeper into it, but have a look at retrieveMainList function there for a work-around and some comments I made about it. – Leonid Shifrin Feb 10 '13 at 1:41
I've reworded the question from "is this a bug and what cases trigger it?" to ask "how do I get the behavior I want out of Save and DumpSave`?" 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
@Tobias This is a good and important questions. Please wait a couple of days, I'd like to see more answers! – Szabolcs Feb 10 '13 at 19:53
My comment certainly does not qualify as an answer, or I would have posted it as such :) – Leonid Shifrin Feb 10 '13 at 21:16