On 21 September 2011 03:15, Schwab,Wilhelm K <bschwab@anest.ufl.edu> wrote:
But how does Fuel "know" that the objects are not otherwise referenced? Â The idea of ignoring weak collections sounds a lot like a compiler optimization that sounds efficient and harmless - sometimes they cause huge problems. Â Think of it this way, if the objects are not otherwise referenced, sure they will be gc's soon - why are are they still around???
the main problem i think is to make fuel to know which objects are belong to your model, and which is not. because in Levente's suggestion, this makes a difference between either serializing a pointer or just replacing it with nil. But then, once you introduce "this object belongs to my model" logic, a new question immediately arises: what if some object strongly referencing an object outside your model? So, the problem is more general than just do it selectively only for weak containers. Either you doing it uniformly (providing facilities to deal with everything which outside your domain/model somehow), or you just walk the graph and storing everything (treating all object found as ones , who belong to your model). And there is nothing special to do with weak containers.
The comments re globally registered objects are well taken too. Â Dolphin's proxies are a great way to handle such things: some objects delegate their serialization to a proxy that contains logic to do global registration, etc.
Bill
________________________________________ From: pharo-project-bounces@lists.gforge.inria.fr [pharo-project-bounces@lists.gforge.inria.fr] On Behalf Of Nicolas Cellier [nicolas.cellier.aka.nice@gmail.com] Sent: Tuesday, September 20, 2011 6:08 PM To: Pharo-project@lists.gforge.inria.fr Subject: Re: [Pharo-project] Should a serializer do something in particular with weak references?
2011/9/21 Levente Uzonyi <leves@elte.hu>:
On Tue, 20 Sep 2011, Mariano Martinez Peck wrote:
Hi guys. Martin and I were discussing whether we should do something in particular in Fuel with Weak references, such as WeakArray. Should we serialize it the same way we serialize all objects, or should we do something special? Â what could be the impact of materializing such weak references in a new image for example?
You should ignore (serialize nil instead of them) the elements of a weak object (#weakSubclass:...) which aren't referenced strongly from other serialized objects.
Levente
Ach, you commited shorter and quicker ;)
Nicolas
Thanks your sharing your thoughts.
-- Mariano http://marianopeck.wordpress.com
-- Best regards, Igor Stasenko.