Caching documentation

15 views
Skip to first unread message

Steve Cumming

unread,
Mar 6, 2018, 6:29:47 PM3/6/18
to SpaDES Users
In the vignette for Caching, many example code chunks contain something like this


where the Copy function is apparently making a deep copy of mySim. The documentation should perhaps explain what this function is doing, as capital-C Cache is mentioned, but never capital-C Copy.




Alex Chubaty

unread,
Mar 6, 2018, 6:41:14 PM3/6/18
to SpaDES Users
`?Copy` leads to the documentation on this function, and is the standard way of accessing manuals in R.

That being said, it's probably worth mentioning why we cache the copy in the first place. I'll add a TO DO item. Thanks.

Eliot McIntire

unread,
Mar 6, 2018, 8:57:55 PM3/6/18
to SpaDES Users
All the *objects* in the simList are pass-by-reference because they are in an environment. That means that objects that are in your "mySim" are the same as the ones in your "mySimOut" ... if there are new objects during simulation, it is not a problem... but any inputs that exist in mySim that are modified during the simulation are modified in mySimOut & mySim ...  you don't get the original values of the inputs even if you look at the mySim.

Steve Cumming

unread,
Mar 12, 2018, 4:59:59 AM3/12/18
to SpaDES Users
Thank you. I think that would help people understand the rest of the Cache documentation better.

Eliot McIntire

unread,
Mar 12, 2018, 5:32:54 PM3/12/18
to SpaDES Users
?simInit -- 3rd sentence states that the objects are pass-by-reference

?Copy - 1st sentence states that all objects are pass-by-reference

Could you please indicate what we can say to make this more clear? It is understandable that one doesn't know why one would want a "deep copy", and that one may not know what "pass-by-reference" means. Please be specific.

Note: this is *not* a Cache issue per se. Cache makes this a little more complicated and the exact behaviour is subtle (and perhaps not fully tested/known). We implemented a non-deep copy approach by default so that the user had control of whether they copy large objects or not.
Reply all
Reply to author
Forward
0 new messages