Creating a system
Our object manager will in turn be an object called ChemicalSystem
, this time built according to the symbol interface method
$ChemicalSystems=1;
ChemicalSystem~SetAttributes~HoldFirst;
$DefaultChemicalSystem:=ChemicalSystem[];
ChemicalSystem[]:=(
$DefaultChemicalSystem=
With[{ID=$ChemicalSystems++},
With[{system=Symbol["ChemicalSystem$"<>ToString@ID]},
system=<|
"ID"->ID,
"Index"->1|>;
ChemicalSystem[system]
]
]);
ChemicalSystem[ID_Integer]:=With[{c=Names@Evaluate["ChemicalSystem$"<>ToString@ID]},
If[Length@c>0,
ToExpression[First@c,StandardForm,ChemicalSystem]
]
]
We’ll reset a default system every time a new system is made so that this system can be used by functions by default.