Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re^3: Managing capture

by Anonymous Monk
on Feb 19, 2013 at 12:12 UTC ( #1019537=note: print w/replies, xml ) Need Help??

in reply to Re^2: Managing capture
in thread Managing capture

Competence is always nice sure, but I don't understand how destructors help. They aren't invoked unless an object is destroyed, which it won't be if it paricipates in a cycle.

I think you understand pefectly :)

If you're accepting callbacks and storing them in an object, you can made a practice of using PadWalker and checking for closures

A slightly simpler check could be made using Devel::Refcount but why bother when PadWalker can do it :)

Replies are listed 'Best First'.
Re^4: Managing capture
by jbert (Priest) on Feb 19, 2013 at 12:55 UTC

    Yes, that would work. However, the drawbacks of this to me are:

    1. the check happens at runtime, not compiletime
    2. it requires each method taking a callback to implement the cycle check. that might be in 3rd party code and so require additional wrapping etc.



      otoh, its cheap check (cheaper than universal competence )

      and simpler to write than a pragma like autovivification -- have you looked at that thing? it walks the perl op-tree using c --- scary :)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1019537]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2018-06-18 06:45 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (109 votes). Check out past polls.