Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88976 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22104 invoked from network); 28 Oct 2015 22:56:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Oct 2015 22:56:33 -0000 Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 217.114.215.10 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 217.114.215.10 mail.experimentalworks.net Received: from [217.114.215.10] ([217.114.215.10:38037] helo=mail.experimentalworks.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B9/C1-08716-0A251365 for ; Wed, 28 Oct 2015 17:56:33 -0500 Received: by mail.experimentalworks.net (Postfix, from userid 1003) id C1BE84F05E; Wed, 28 Oct 2015 23:56:35 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on km31408.keymachine.de X-Spam-Level: X-Spam-Status: No, score=-1.0 required=4.0 tests=ALL_TRUSTED autolearn=unavailable autolearn_force=no version=3.4.0 X-Spam-HAM-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP Received: from [192.168.2.34] (ppp-93-104-6-87.dynamic.mnet-online.de [93.104.6.87]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: johannes@schlueters.de) by mail.experimentalworks.net (Postfix) with ESMTPSA id 721294F05E; Wed, 28 Oct 2015 23:56:33 +0100 (CET) Message-ID: <1446072986.4127.63.camel@kuechenschabe> To: Rowan Collins Cc: internals@lists.php.net Date: Wed, 28 Oct 2015 23:56:26 +0100 In-Reply-To: <5630FBC1.4000806@gmail.com> References: <5630DE79.8070205@gmail.com> <5630FBC1.4000806@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] In a destructor, how to detect if an exception is currently in flight? From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) 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