Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58252 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7221 invoked from network); 28 Feb 2012 16:13:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Feb 2012 16:13:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=arvids.godjuks@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=arvids.godjuks@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.170 as permitted sender) X-PHP-List-Original-Sender: arvids.godjuks@gmail.com X-Host-Fingerprint: 209.85.212.170 mail-wi0-f170.google.com Received: from [209.85.212.170] ([209.85.212.170:45568] helo=mail-wi0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C3/A1-34356-91DFC4F4 for ; Tue, 28 Feb 2012 11:13:14 -0500 Received: by wibhm4 with SMTP id hm4so4181417wib.29 for ; Tue, 28 Feb 2012 08:13:11 -0800 (PST) Received-SPF: pass (google.com: domain of arvids.godjuks@gmail.com designates 10.181.11.227 as permitted sender) client-ip=10.181.11.227; Authentication-Results: mr.google.com; spf=pass (google.com: domain of arvids.godjuks@gmail.com designates 10.181.11.227 as permitted sender) smtp.mail=arvids.godjuks@gmail.com; dkim=pass header.i=arvids.godjuks@gmail.com Received: from mr.google.com ([10.181.11.227]) by 10.181.11.227 with SMTP id el3mr40047954wid.18.1330445591167 (num_hops = 1); Tue, 28 Feb 2012 08:13:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=gtc53CQ0QU6cbxbN9c3/4WyGjU/CNlOpWIEGYI5IEEU=; b=SMhRQyXv32YyiKnQHq0DLzon5GBoaGnl0gLBcgE0vEWU/9+y902NFyX2fX7JWbby85 3GNMg0LblhK/WycrE18wZNrCUaVqPvJAi6W1d75FxtQxfl8ZaYte7+JD39cJfJRz7NEp nRzODWmxKwDVFaiW0dQHSAO/c2npj7xSkl3Jo= Received: by 10.181.11.227 with SMTP id el3mr31681609wid.18.1330445591079; Tue, 28 Feb 2012 08:13:11 -0800 (PST) MIME-Version: 1.0 Received: by 10.227.117.1 with HTTP; Tue, 28 Feb 2012 08:12:51 -0800 (PST) In-Reply-To: References: <01a901ccf622$0645f230$12d1d690$@alliantinternet.com> Date: Tue, 28 Feb 2012 18:12:51 +0200 Message-ID: To: Richard Lynch Cc: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Possibility to add finally to try/catch? From: arvids.godjuks@gmail.com (Arvids Godjuks) It's quite hard to think of a compelling example. Usually you just write the code and realize that "Yea, a 'finally' statement would make a lot of sense here". I believe it's the kind of functionality that you learn to use in time, just like __set, __get, __sleep, __wakeup. If first two are no brainier these days, the last two to me where "wtf? does anyone use that? Where I need them at all?!". It was like that for 3-4 years. Until I got the code witch actually made an active use of these two and I understood the purpose. Same goes to finally. I remember using in JavaScript a few times, helped a = lot. And it just makes sense to add to complete the try {} catch {} finally {} template. My 2 cents. 2012/2/28 Richard Lynch : > On Tue, February 28, 2012 8:22 am, 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 { >> =C2=A0 =C2=A0 $fh =3D fopen($filename); >> >> =C2=A0 =C2=A0 // Do some work on the file + encounter an error. >> =C2=A0 =C2=A0 throw new Exception(); >> } catch (Exception $e) { >> =C2=A0 =C2=A0 // Log an error or something > + =C2=A0 =C2=A0 =C2=A0 if ($fh) fclose($fh); //many PHP file errors NULL = out the $fh > + =C2=A0} > - > } finally { > - > =C2=A0 =C2=A0 fclose($fh); > - > } > > Another non-compelling example... > > Still not saying "finally" is a bad idea. > > Just want a compelling use case before I would vote... > > -- > brain cancer update: > http://richardlynch.blogspot.com/search/label/brain%20tumor > Donate: > https://www.paypal.com/cgi-bin/webscr?cmd=3D_s-xclick&hosted_button_id=3D= FS9NLTNEEKWBE > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >