in reply to return weak reference

When I wrote it, I intended that the first call to the constructor would return the "master" reference, subsequent calls would return weak references.

What's your reasoning for doing so?

(I can imagine why you might think you need to do so, if you've a background writing C code or maintaining awful C++ code, but I can't imagine a situation in Perl where this is necessary.)

Replies are listed 'Best First'.
Re^2: return weak reference
by flipper (Beadle) on Sep 02, 2010 at 10:26 UTC

    Yep, you're right - as above, I don't need to do what I was originally after so long as I don't go around making problems for myself :-)

    It's a fairly large framework (~25kloc) for testing SMTP/HTTP etc content scanning proxies. By design, bits of it are quite tightly coupled - the benefit is that it's easy for non-programmers to use - you call Foo::Protocol::SMTP->new(content => spam, ....), the SMTP constructor calls into the rig objects, gets access to machine objects, configures itself appropriately, then when you call $smtp->execute() it connects to RPC daemons on various machines, and does the things you ask for, and collects tcpdumps/logs if it fails.

    Things are futher complicated by the fact that it started life as a god object - I did a serious refactor, but as there were dozens of scripts already using the god object, I had to put in a shim layer to make the old stuff work.