Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58239 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85750 invoked from network); 28 Feb 2012 14:36:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Feb 2012 14:36:32 -0000 Authentication-Results: pb1.pair.com header.from=simonsimcity@googlemail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=simonsimcity@googlemail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.214.170 as permitted sender) X-PHP-List-Original-Sender: simonsimcity@googlemail.com X-Host-Fingerprint: 209.85.214.170 mail-tul01m020-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:49731] helo=mail-tul01m020-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 60/90-17048-E66EC4F4 for ; Tue, 28 Feb 2012 09:36:31 -0500 Received: by obbwd1 with SMTP id wd1so340501obb.29 for ; Tue, 28 Feb 2012 06:36:27 -0800 (PST) Received-SPF: pass (google.com: domain of simonsimcity@googlemail.com designates 10.182.36.106 as permitted sender) client-ip=10.182.36.106; Authentication-Results: mr.google.com; spf=pass (google.com: domain of simonsimcity@googlemail.com designates 10.182.36.106 as permitted sender) smtp.mail=simonsimcity@googlemail.com; dkim=pass header.i=simonsimcity@googlemail.com Received: from mr.google.com ([10.182.36.106]) by 10.182.36.106 with SMTP id p10mr6850802obj.55.1330439787481 (num_hops = 1); Tue, 28 Feb 2012 06:36:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=arWtW4wU8v/22m/eLLZFtYD5yv2h/7Z2qbRWM1wTgLM=; b=Vpv5F64TAGNMupNfBQ0gitUjL/kqDJL0s5w/zjz/iHtLgJaeOMpZjigNrjlCUehh2f RqTZGqD8Okb+dl/YTCHImz4dCdd2yCewn9pleQXWgBC+Ulzg16UVmeThvb7wuc6Y7IN6 kd8d8nZiCKIPaH386i2EceHmi4we8zXw+z7qQ= MIME-Version: 1.0 Received: by 10.182.36.106 with SMTP id p10mr6035541obj.55.1330439787356; Tue, 28 Feb 2012 06:36:27 -0800 (PST) Received: by 10.60.7.229 with HTTP; Tue, 28 Feb 2012 06:36:27 -0800 (PST) In-Reply-To: References: <01a901ccf622$0645f230$12d1d690$@alliantinternet.com> Date: Tue, 28 Feb 2012 15:36:27 +0100 Message-ID: To: Dmitri Snytkine Cc: Paul Dragoonis , Kiall Mac Innes , internals@lists.php.net Content-Type: multipart/alternative; boundary=f46d04447eebeba23c04ba07266f Subject: Re: [PHP-DEV] Possibility to add finally to try/catch? From: simonsimcity@googlemail.com (Simon Schick) --f46d04447eebeba23c04ba07266f Content-Type: text/plain; charset=UTF-8 Hi, Dmitri Great that someone's mentioning it. I thought about that several times but did not put it in here. This is a must-have for me. Really useful if you're working with external resources (streams, database connection etc). I used a destructor until now for stuff like that but there are some situations where a destructor won't be called. http://stackoverflow.com/questions/2385047/when-will-destruct-not-be-called-in-php Bye Simon 2012/2/28 Paul Dragoonis > 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 > > > > > > > > > --f46d04447eebeba23c04ba07266f--