Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58236 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81820 invoked from network); 28 Feb 2012 14:26:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Feb 2012 14:26:04 -0000 Authentication-Results: pb1.pair.com smtp.mail=dragoonis@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dragoonis@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.83.42 as permitted sender) X-PHP-List-Original-Sender: dragoonis@gmail.com X-Host-Fingerprint: 74.125.83.42 mail-ee0-f42.google.com Received: from [74.125.83.42] ([74.125.83.42:42641] helo=mail-ee0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B3/50-14730-AF3EC4F4 for ; Tue, 28 Feb 2012 09:26:03 -0500 Received: by eekb57 with SMTP id b57so1557127eek.29 for ; Tue, 28 Feb 2012 06:25:59 -0800 (PST) Received-SPF: pass (google.com: domain of dragoonis@gmail.com designates 10.112.24.4 as permitted sender) client-ip=10.112.24.4; Authentication-Results: mr.google.com; spf=pass (google.com: domain of dragoonis@gmail.com designates 10.112.24.4 as permitted sender) smtp.mail=dragoonis@gmail.com; dkim=pass header.i=dragoonis@gmail.com Received: from mr.google.com ([10.112.24.4]) by 10.112.24.4 with SMTP id q4mr7920177lbf.80.1330439159698 (num_hops = 1); Tue, 28 Feb 2012 06:25:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=T4MRX6wE73AFq6NzSng6GLdI/P0W+wXJIXy/IyurZQA=; b=vozpi5VzEcyjbnSFUZdjKwGm5xtRNQT2hSNGAcai88i/yoB8L/Eipp8LqzDxeAKrF3 4dJp2o9QW+MEb1TA0IZYPgmKraZJj0le9abwTqS1WQqeRiFnOg74FHhcJIGPpjZEd4XF FvfkAtoI9PddcZARv0xWpIPq+hEOXA5LNAtDA= MIME-Version: 1.0 Received: by 10.112.24.4 with SMTP id q4mr6643139lbf.80.1330439159598; Tue, 28 Feb 2012 06:25:59 -0800 (PST) Received: by 10.152.134.82 with HTTP; Tue, 28 Feb 2012 06:25:59 -0800 (PST) In-Reply-To: References: <01a901ccf622$0645f230$12d1d690$@alliantinternet.com> Date: Tue, 28 Feb 2012 14:25:59 +0000 Message-ID: To: Kiall Mac Innes Cc: Dmitri Snytkine , internals@lists.php.net Content-Type: multipart/alternative; boundary=e0cb4efe31b480cee604ba0701bc Subject: Re: [PHP-DEV] Possibility to add finally to try/catch? From: dragoonis@gmail.com (Paul Dragoonis) --e0cb4efe31b480cee604ba0701bc Content-Type: text/plain; charset=ISO-8859-1 Tried to do something the other day and had to write something a bit quirky tht would have been super clean with a finally block. +1000 On Tue, Feb 28, 2012 at 2:22 PM, Kiall Mac Innes wrote: > +1000 > > This is a feature that I've always wanted in PHP, My main reason being to > reduce code duplication. eg > > try { > $fh = fopen($filename); > > // Do some work on the file + encounter an error. > throw new Exception(); > } catch (Exception $e) { > // Log an error or something > } finally { > fclose($fh); > } > > Thanks, > Kiall > > > On Tue, Feb 28, 2012 at 2:05 PM, Dmitri Snytkine < > dsnytkine@ultralogistics.com> wrote: > > > > > This is another feature that we know we can live without > > but those familiar with languages that have 'finally' like Java or Python > > know that > > it is very neat feature to have in some situations. > > > > Basically the code inside 'finally' is guaranteed to run even if there > is a > > 'return' inside try or catch blocks > > in which case the value to be returned is remembered tempraraly, the code > > inside finally block executes and then remembered value is returned. > > > > > > Dmitri Snytkine > > Web Developer > > Ultra Logistics, Inc. > > Phone: (888) 220-4640 x 2097 > > Fax: (888) 795-6642 > > E-Mail: dsnytkine@ultralogistics.com > > Web: www.ultralogistics.com > > > > "A Top 100 Logistics I.T. Provider in 2011" > > > > > > > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > --e0cb4efe31b480cee604ba0701bc--