Phil,

Philip Clayton wrote:
My understanding of loading a state is that new objects are created whether or not the same object is already loaded. That seems the right thing to do, as you say. When loading a child state however, I would expect only objects in the child state to be created and any objects not in the child to remain as they are. This does not appear to fit with our observations in relation to threads though. Loading a child state appears to prevent a running thread from picking up the latest mutable data, even though all objects used in the running thread are not in the child state. I can't recreate the issue without threads. I've updated the previous example to show this.

I've had a look through your example and I'm not certain exactly what's going on but I think the answer is that loading a child state always (re)loads the parents, at least as the code is currently implemented. This causes a new version of your ref "c" to be created and breaks the link between the ref that the thread is using and the ref that is found by looking up "c".

I guess it would be possible to change this so that saved states that were already loaded were not reloaded. I can't think of any reasons why this wouldn't work. It would require changes to the code. However, I wonder if it's what users would always want. Aren't there cases where a user might want loadState on a child to restore the whole state?

David

_______________________________________________
polyml mailing list
polyml@inf.ed.ac.uk
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml

Reply via email to