Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61688 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4556 invoked from network); 24 Jul 2012 14:47:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Jul 2012 14:47:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=laruence@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=laruence@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.42 as permitted sender) X-PHP-List-Original-Sender: laruence@gmail.com X-Host-Fingerprint: 209.85.212.42 mail-vb0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:40290] helo=mail-vb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F5/08-17533-A95BE005 for ; Tue, 24 Jul 2012 10:47:54 -0400 Received: by vbbfs19 with SMTP id fs19so6685103vbb.29 for ; Tue, 24 Jul 2012 07:47:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=CnA+bWxMo0s4DAMmrI7+srB6SVX/dSmuzvLJflzEs/k=; b=QfBsLYgsaSqylO2di71iv05XC1CA//6/92SCjZCwOjpPqbxa1+y8iDw1tVCrCzQptZ m6unAS4XcXse0CrKnTjdfUDJf6hSP8pFyepP5kUCqDIIVNgvil5nYVP1HA8rsuZvIpCT Hc6lrHKGdMI6E52ih98JbdLI7VnwOqBrDRgp8emOWpqV8/ZUcClPmY49dNwF9/sF8KyR Mr1x5duyRwOU6S+gNcMNI+3RhZBdXUUQDyfqU+QcGWA5P7X2SENaxQNoYu93S626SkVQ HSWmfGRn0ruU9Pu4uJnvem0mY5Y2D2s7B8RSr7XX37CW4B2MjCNwKG83I+cJNZ8khb2J lzkg== Received: by 10.52.33.82 with SMTP id p18mr8430931vdi.132.1343141271089; Tue, 24 Jul 2012 07:47:51 -0700 (PDT) MIME-Version: 1.0 Sender: laruence@gmail.com Received: by 10.220.195.3 with HTTP; Tue, 24 Jul 2012 07:47:30 -0700 (PDT) In-Reply-To: References: Date: Tue, 24 Jul 2012 22:47:30 +0800 X-Google-Sender-Auth: 2KjTKpTkwCrJPZibK45oVq38pFA Message-ID: To: Nikita Popov Cc: PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Supports 'finally' keyword for PHP exceptions From: laruence@php.net (Laruence) On Tue, Jul 24, 2012 at 9:35 PM, 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. I am really can not agree with you on this point. there is runtime error and static error in PHP. it is enough for finally guarantee that the block will be run while *Exception* threw. if in your opinion, then I think finally is also nouse for java, since user could also call exit(some like that ). thank > > 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 -- Laruence Xinchen Hui http://www.laruence.com/