# Not FullDefinition for Save. MachineID not Protected?

Is there a way to set what symbols's definitions I do not want to store?

Consider the following code:

f := $MachineID; SetDirectory[NotebookDirectory[]]; Save["testm.m", f]; ClearAll@f << "testm.m" f  Set::specset: Cannot change the value of special symbol$MachineID. >>
0000-00000-00001 (*id of storing machine*)
0000-00000-00002 (*id of getting machine*)


This happens bacause testm.m contains:

f := $MachineID$MachineID = "0000-00000-00001"


Questions:

• Is there nicer way to avoid this than my approach:

f:= Symbol["MachineID"]


?

• Is it Protected attribute which decides what is going to be stored? Because there is no problem if f:=SystemID but:

Attributes[{$SystemID,$MachineID}]

{{Locked, Protected}, {}}


Edit:

• Why MachineID is not protected? - The bounty is founded for this question.
-
Nice question! I agree that it seems odd that $MachineID is not Protected – Jacob Akkerboom Aug 27 '13 at 11:42 @JacobAkkerboom Hello,:) yes, in fact I wouldn't have known this but there is something else what causes the error msg and without this my MachineID could have been distributed :D. – Kuba Aug 27 '13 at 11:45 ah yes, I guess that could be a privacy issue. – Jacob Akkerboom Aug 27 '13 at 12:03 I am unhappy that you have asked two very different questions here causing two separate answer threads to come into existence for this one question. It makes a confusing mess for anyone trying to figure out what this post is really about. You really should have posted two questions. – m_goldberg Aug 27 '13 at 21:46 @m_goldberg You are right. I was too hasty (again :() and the question was evolving, even though it was posted, and ended up not well suited for the site. I will try rephrase it tomorrow so it will fit the answers and the leftovers move to the separate question. – Kuba Aug 27 '13 at 22:21 show 5 more comments ## 2 Answers From the documentation: Save: Save uses FullDefinition to include subsidiary definitions. FullDefinition: FullDefinition[symbol] recursively prints as all definitions for the symbol, and for the symbols that appear in these definitions, unless those symbols have the attribute Protected. So if you want to not save $MachineID you could do:

Protect[$MachineID]; Save["testm.m", f]; Unprotect[$MachineID];

-
Thank you, it seems I have to dig more in documentation next time :) –  Kuba Aug 27 '13 at 11:05
Don't you think it is strange that $MachineID is not protected? – Kuba Aug 27 '13 at 11:05 add comment Extended comment I found the following interesting. I guess this happens for more Symbols than just $MachineID. The following tries to assign to special symbols starting with a $and gives an overview of whether that was allowed and what the attributes are. Warning: you may want to restart the kernel after this. list = Function[ xxxx, {HoldForm[xxxx], Check[xxxx = xxxx; "succes", "failure"], Sequence @@ Attributes[xxxx]}, HoldAllComplete] @@ ToExpression[#, InputForm, HoldComplete] & /@ DeleteCases[Names["$*"], "$PrePrint" | "$Pre" | "$Post"]; list // TableForm (*gives a big table*)  The following then gives a list of symbols similar to $MachineID in this respect

Select[list,
Function[Not[FreeQ[#, "failure"]] && FreeQ[#, Protected]]] // Column

(*output*)

{$ActivationGroupID,failure} {$ActivationKey,failure}
{$ActivationUserRegistered,failure} {$InputFileName,failure}
{$LicenseExpirationDate,failure} {$LicenseID,failure}
{$LicenseProcesses,failure} {$LicenseServer,failure}
{$LicenseSubprocesses,failure} {$LicenseType,failure}
{$MachineAddresses,failure} {$MachineDomain,failure}
{$MachineDomains,failure} {$MachineID,failure}
{$MachineName,failure} {$MaxLicenseProcesses,failure}
{$MaxLicenseSubprocesses,failure} {$NetworkLicense,failure}
{$ParentProcessID,failure} {$PatchLevelID,failure}
{$ProcessID,failure} {$UserName,failure}

-
Thanks, I'm curious why it is so. Btw. what causes the error masg if the symbol is not protected? –  Kuba Aug 27 '13 at 12:28
@Kuba I don't know, the documentation has no special entry on this message. I suppose that that is a specific message just for special symbols. That is, the ones above, and probably similar symbols that do have Protected as well. –  Jacob Akkerboom Aug 27 '13 at 12:33