Re: [PHP-DEV] exceptions in the destructor

2005-12-20 Thread Marcus Boerger
Hello Daine, as far as i can tell that assumption is correct. Destructor calls are not reliable in shutdown. That is they are at one point all called. For any destructor that creates a new object the destructor of that new object might not be called. Plus a bunch of other unexpected behavior.

Re: [PHP-DEV] exceptions in the destructor

2005-12-20 Thread Daine Mamacos
I see where all this is going. As long as the destructor is not called as part of the cleanup code, it works fine. Is that assumption correct? On Wed, 21 Dec 2005 00:14:15 +, Daine Mamacos wrote > Marcus, > I'm not trying to argue with you, I'm just after some help. > You are confusing me som

Re: [PHP-DEV] exceptions in the destructor

2005-12-20 Thread Daine Mamacos
Marcus, I'm not trying to argue with you, I'm just after some help. You are confusing me somewhat. The php manual clearly states: "Note: Attempting to throw an exception from a destructor causes a fatal error." I'm somewhat convinced that you cannot throw an exception from a destructor, well you ca

Re: [PHP-DEV] exceptions in the destructor

2005-12-20 Thread Marcus Boerger
Hello Daine, > a) i didn't contradict myself - you obviously didn't really follow >what i wrote > b) you can force calling the destructor by using unset() or = null; >but only if reference count is 1. > c) exceptions are 'thrown' not called, maybe you didn't use throw new >exception h

Re: [PHP-DEV] exceptions in the destructor

2005-12-20 Thread Alan Pinstein
I also would like someone to tell me why exceptions cannot be called in the destructor? Since they can't, this means the reliability of a destructor is uncontrolled and nothing can be done to see if this completes successfully. Your question is kindof wrong... you can always throw exception

Re: [PHP-DEV] exceptions in the destructor

2005-12-20 Thread Marcus Boerger
Hello Daine, a) i didn't contradict myself - you obviously didn't really follow what i wrote b) you can force calling the destructor by using unset() or = null; but only if reference count is 1. c) exceptions are 'thrown' not called, maybe you didn't use throw new exception here or you

Re: [PHP-DEV] exceptions in the destructor

2005-12-20 Thread Daine Mamacos
I agree completely... I think the GC should be better documented. I also would like someone to tell me why exceptions cannot be called in the destructor? Since they can't, this means the reliability of a destructor is uncontrolled and nothing can be done to see if this completes successfully. This

Re: [PHP-DEV] exceptions in the destructor

2005-12-20 Thread Jochem Maas
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,

Re: [PHP-DEV] exceptions in the destructor

2005-12-20 Thread Alan Pinstein
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 term

Re: [PHP-DEV] exceptions in the destructor

2005-12-20 Thread Daine Mamacos
I'm not trying to argue here, I just asked a question, and you've managed to contradict your first post. I just asked why this is the case, and if it is, is there any way I can work WITH this functionality. Your last post also indicates, that because the destructors are only called after script t

Re: [PHP-DEV] exceptions in the destructor

2005-12-16 Thread Marcus Boerger
Hello Daine, [EMAIL PROTECTED] /usr/src/PHP_5_1 $ php -r 'class A{function __destruct(){throw new Exception("A");}} new A;' make: `sapi/cli/php' is up to date. Fatal error: Uncaught exception 'Exception' with message 'A' in Command line code:1 Stack trace: #0 Command line code(1): A::__destruct

[PHP-DEV] exceptions in the destructor

2005-12-16 Thread Daine Mamacos
Is there any reason why one is not allowed to throw an exception in the destructor of a class? I mean, it makes sense, considering this is not always the final step of code, and it is usually used for finalising things, and it would be a good idea to know if anything goes wrong at that stage. Other