SetReplace
SetReplace copied to clipboard
Improve evolution object corruption checking
The problem
Currently we assume evolution objects are guaranteed to have correct format as long as they have correct keys in the Association
. Of course, it is not correct, as the user can manually modify them, which yields cryptic internal messages:
In[] := WolframModelEvolutionObject[<|"CreatorEvents" -> 0,
"DestroyerEvents" -> 0, "Generations" -> 0, "AtomLists" -> 0,
"Rules" -> 0, "MaxCompleteGeneration" -> 0,
"TerminationReason" -> 0, "EventRuleIDs" -> 0|>]["CausalGraph"]

Expected behavior
We should not assume the evolution object is correct when evaluating properties, and should produce WolframModelEvolutionObject::corrupt
if we detect something is wrong.
Note, complete checking should not happen preemptively, because that could be very slow.
Version
In[] := SystemInformation["Small"]

In[] := $SetReplaceGitSHA
9620568bf18c009a472399a27f0bc546dfeb8fe0
Should be useful (from #wolfram-language discord channel):
getFooData[Foo[_,_,assoc_]] := assoc;
Foo[assoc_Association] ? System`Private`HoldNoEntryQ := (
(* check that assoc is valid *)
System`Private`ConstructNoEntry[Foo, assoc]
)
myAPIFunction[foo_Foo ? System`Private`NoEntryQ] :=
getFooData[foo]
Also: https://mathematica.stackexchange.com/questions/198378/custom-atomic-expressions-modern-tutorial