develooper Front page | perl.perl5.porters | Postings from June 2009

Re: DESTROY: is there any predictability about when it's called?

Thread Previous | Thread Next
From:
Eirik Berg Hanssen
Date:
June 13, 2009 08:16
Subject:
Re: DESTROY: is there any predictability about when it's called?
Message ID:
7xiqj06u83.fsf@blackbox.eirik.dav
Andy Armstrong <andy@hexten.net> writes:

> On 5.10 the my ( undef ) = ( $state ) seems to work to force $state to
> be destroyed late enough to avoid false positives - but that's a bit
> heuristic for my tastes. Is there a reliable way to flush pending
> DESTROYs or some other way to guarantee that $state is lives longer
> than anything allocated by $block?

  With no clue as to the internals ...

  I think what you're doing _should_ work.  DESTROY gets called at
scope exit if not earlier, so on leaving the $block's scope, all
DESTROYs of objects now out of scope will be called – and since you
reference $state at a later point, it will need to remain alive, and
its DESTROY not yet called.

  At least, I have assumed it.  Silly me?


Eirik
-- 
All the books you read and courses you take in college are just there to help
you get familiar with the brushes and the canvas.  They'll help keep you from
making brown blobs, but you'll never make a masterpiece by the book.
  -- Robert Simpson, mail-archive.com/sqlite-users%40sqlite.org/msg14592.html

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About