Alan Pinstein wrote:
Your last post also indicates, that because the destructors are only
called
after script termination, the scope of an object is global, always.
Is this true?
This isn't true, at least empirically. Destructors are called when the
GC frees the object.
For many objects, this is at script termination. But if you null out
the ref to an object, it will occur immediately.
$a = new A();
$a = null; // destructor called just after this line
I am not certain that this should be considered *predictable* behavior,
as the behavior of the GC is not well/publicly documented to my
knowledge, and thus this is a reasonable question for the internals list.
Personally I would like to see more documentation of how GC works so
that we as developers can depend on it a little better for OO cleanup
activities. I have another thread going that still remains unanswered
about how to prevent circular references to objects that deadlock the GC.
I feel the usefulness of the dtors is undermined even more by the
'chiken/egg' problem regarding which comes first 'shutdown' or 'running the
dtors';
I don't claim to have a solution or even understand the problem fully but it
does seem to me that for most of the things an average developer would think of
using object dtors for, the mechanism is unusable; and from what I understand
the
'chicken/egg' problem I mentioned has been an ongoing PITA for devs!
(IIRC Wez mentioned the to-ing and fro-ing regarding this not so long ago)
Phorce be with you. (excuse me, but I have just had my annual starwars fix :-)
Alan
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php