Re: In a destructor, how to detect if an exception is currently in flight?

From: Date: Wed, 28 Oct 2015 22:56:26 +0000
Subject: Re: In a destructor, how to detect if an exception is currently in flight?
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-88976@lists.php.net to get a copy of this message
On Wed, 2015-10-28 at 16:45 +0000, Rowan Collins wrote: > On the downside, it's worth noting that while PHP destructors are > technically deterministic, the language can actually prevent them > running on scope exit, because Exceptions hold references to everything > used as a parameter in their stack traces. > > In the below very simple example, both err() and foo() have completed, > but the destructor fires only once the Exception is caught and > discarded. So if you passed your ScopeGuard object around at all, you > might find things executing in a surprising order. That's an interesting case, I in fact didn't think about, but I believe a scope guard / RAII object should not be passed to another scope. johannes

« previous php.internals (#88976) next »