Dear Nick Ing-Simmons, in your previous mail you wrote:
> >There's nothing fundamentally evil about setting the refcount to a lower
> >value, because this just triggers the DESTROY() event sooner than it would
> >normally. Since after receiving this event the correct refcount is restored,
>
> You cannot always acually _do_ that - you can try but it does not work
> in some cases:
>
> if (SvREFCNT(sv)) {
> if (PL_in_clean_objs)
> Perl_croak(aTHX_ "DESTROY created new reference to dead object
>'%s'",
> HvNAME(stash));
>
> So in order to play such games you must be 100% sure there are, and will
> not be, any "extra" REFCNTs that will delay your "event" to final cleanup stage.
> Extra REFCNTs are all too easy to create ... been there.
That's why I *ADD BACK* the previously subtracted number of references instead
of simply restoring the initial value. This takes care of extra references which
have been created in the meantime.
And I failed to mention that I also have an END() routine which restores all the
refcounts before the final garbage collection (= Perl interpreter shutdown).
That way Perl doesn't get to see the wrong refcounts even if additional references
have been created which prevented the objects from going out of scope before the
global destruction.
Regards,
--
Steffen Beyer <[EMAIL PROTECTED]>
http://www.engelschall.com/u/sb/whoami/ (Who am I)
http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)