|Do you know where your variables are?|
Managing objects/references across system boundariesby Corion (Pope)
|on Oct 23, 2009 at 14:58 UTC||Need Help??|
Corion has asked for the
wisdom of the Perl Monks concerning the following question:
It could be written like this in Perl:
The Perl implementation of the objects is very simple:
and the JS side of the bridge implements repl.breakLink() as:
which can be translated to Perl as
This all works fine and dandy, objects get created, handed around within Perl space, and released once all Perl code is done with them.
But (and you knew there was this small niggle), there is one small problem:
creates two different references to the same object, and refaddr claims I have two different objects. During the writing of this node, I've come up with three solutions, one I find good, one I find bad and one I find ugly. I'd like your input on the three solutions and potentially other solutions that allow me to emulate checking the object identity in Perl without having to reimplement reference counting.
PS: If you want to look at the real code instead of my mock example,
it lives in a github repository,
and the main code I write this for is WWW::Mechanize::FireFox.
Update: Linked to released module, fixed markup