Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61681 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93410 invoked from network); 24 Jul 2012 13:44:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Jul 2012 13:44:24 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 64.22.89.133 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 64.22.89.133 oxmail.registrar-servers.com Linux 2.6 Received: from [64.22.89.133] ([64.22.89.133:36440] helo=oxmail.registrar-servers.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 54/95-17533-7B6AE005 for ; Tue, 24 Jul 2012 09:44:24 -0400 Received: from [192.168.0.200] (5ad32874.bb.sky.com [90.211.40.116]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by oxmail.registrar-servers.com (Postfix) with ESMTPSA id 25714C300CC for ; Tue, 24 Jul 2012 09:44:19 -0400 (EDT) Message-ID: <500EA69F.2040908@ajf.me> Date: Tue, 24 Jul 2012 14:43:59 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Supports 'finally' keyword for PHP exceptions From: ajf@ajf.me (Andrew Faulds) On 24/07/12 14:40, Levi Morrison wrote: > On Tue, Jul 24, 2012 at 7:35 AM, Nikita Popov wrote: >> On Tue, Jul 24, 2012 at 1:20 PM, Laruence wrote: >>> Hi: >>> As the previous threads disscussed, I make a implemention. >>> >>> here is the RFC: https://wiki.php.net/rfc/finally >>> >>> any suggestions? >> The finally clause comes with a very strong promise that the code in >> the clause will run in absolutely any case (short of sigkill, maybe). >> In particular this means that... >> ... if a die() is execute somewhere in the try clause (or a called >> function) the finally clause must still be run. >> ... if a parse error or other fatal error occurs in the try clause (or >> called function) the finally clause must still be run. >> ... if the user interrupts the process the finally clause must still be run. >> >> Basically this requires that all of the actions that are currently >> fatal need to be converted to exceptions. E.g. Python has special >> SystemExit and KeyboardInterrupt exceptions, as well as SyntaxError >> and so on. >> >> I obviously think that PHP should adopt this model too (as it gives >> the programmer more control), but until all fatal actions are turned >> into exceptions, I'm strongly against introducing "finally". The main >> point of the clause is to have a guarantee, and that is simply >> currently not present. You actually get a better guarantee if you just >> use destructors. >> >> Nikita >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> > I definitely agree with Mr. Nikita Popov. Unless we have a > guarantee of `finally` running for PHP fatal errors, then this is not > particularly useful. > I also agree with Mr. Popov here. PHP's fatal errors are, well, fatal, meaning we can do absolutely nothing about them. I guess that's something to change for PHP6: making them into serious exceptions, but ones that can be caught (maybe a different class, like Java's RuntimeErrors and Exceptions, IIRC). Obviously things like running out of memory can't be dealt with, though.