Igor,<br><br><div class="gmail_quote">On Thu, Sep 23, 2010 at 1:23 PM, Igor Stasenko <span dir="ltr">&lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello,<br>
<br>
i&#39;d like to raise this subject once more, because i don&#39;t like it (or<br>
don&#39;t understand?).<br></blockquote><div><br></div><div>This is a straw man since actions compose.  i.e. if one wanted multiple finalization actions on a single object one would create a unitary action that invoked multiple sub-actions.  i.e. you can lift the problem up.  If someone ever needs multiple finalization actions they can query the existing finalization action, compose this with a new finalization action and install the compound as the single action.</div>
<div><br></div><div>2¢</div><div>Eliot</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
In all scenarios, where i met the need to use finalization, a single<br>
finalizer is sufficient.<br>
Moreover, there is always a single object who controls a weak<br>
reference, and it never leaks it out, to prevent<br>
the case, when some other object may obtain a strong reference on it,<br>
making it permanently held in object memory.<br>
<br>
Multiple different finalizers for single object, from design point of<br>
view, means that you having two different, not related frameworks,<br>
which using same object, and want to do something when it dies.<br>
A scenario, where its possible and userful, still don&#39;t comes into my mind.<br>
In contrary, whenever i see a use of finalizers, its in most cases<br>
about graceful control over external resource, such as:<br>
- file<br>
- socket<br>
- external memory<br>
<br>
and i really don&#39;t see how multiple finalizers per single resource<br>
could do any good.<br>
<br>
Suppose one finalizer closing a file handle, while another one<br>
flushing it buffer cache.<br>
Now, how you going to ensure, that one finalizer will execute first,<br>
before another one?<br>
And what if third framework comes into play and wants to add another<br>
finalizer on top of that, which should do something in the middle<br>
between flushing a cache and closing file handle?<br>
<br>
&gt;From the above, the only conclusion can be made: use a single<br>
finalizer, and put all logic &amp; operation ordering into it.<br>
And also, prevent leakage of object pointer (such as file handle)<br>
outside of your model, otherwise it may cause harm.<br>
<br>
That&#39;s why i think a current WeakRegistry model provoking bad design practices.<br>
I think a better behavior would be to raise an error, if something<br>
wants to register finalizer twice for a single object.<br>
<font color="#888888"><br>
<br>
--<br>
Best regards,<br>
Igor Stasenko AKA sig.<br>
<br>
</font></blockquote></div><br>