Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67183 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95474 invoked from network); 27 Apr 2013 18:23:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Apr 2013 18:23:03 -0000 Authentication-Results: pb1.pair.com header.from=amaury.bouchard@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=amaury.bouchard@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.179 as permitted sender) X-PHP-List-Original-Sender: amaury.bouchard@gmail.com X-Host-Fingerprint: 209.85.216.179 mail-qc0-f179.google.com Received: from [209.85.216.179] ([209.85.216.179:47381] helo=mail-qc0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E2/00-29666-6871C715 for ; Sat, 27 Apr 2013 14:23:02 -0400 Received: by mail-qc0-f179.google.com with SMTP id v28so2478452qcm.38 for ; Sat, 27 Apr 2013 11:22:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=KYH3RSJDqGyAwgLvnSTE88CsaeNVM7x185p4xrlGg3s=; b=xviaIoyHNmZ2Kn5nroDIiDNFoyk4cn3+GJ9+g63T/NLW6AMSUmRzGSJRFmcaTTiApt 3xJ8Xe7yzHbgrZYdGjh+MULj9Cn4cYjD6HLFwxIK2yXI01ADPUHQMqzMGIgmk2p75xYU qdidP8BveQ/nqV1EqgoIm5LE9ftj2+1OYnrFjNJL7MlSfVfVBDr89P/N/c5CfmEmFA1M Wdg6uU5wJJpOZ2I3LECaMRr1Rkhp4puE3rnQQ5LoPNm0V06BGxFYDFF/j1x9BdaV+T8/ 3E7wlGtg70A6UXdMY7zj8Wrtau0JbSqiAVdaQMRlDB9ZXpIrRqSGg653OV5XYMFLIpFJ Na/w== X-Received: by 10.229.150.199 with SMTP id z7mr3636306qcv.25.1367086979140; Sat, 27 Apr 2013 11:22:59 -0700 (PDT) MIME-Version: 1.0 Sender: amaury.bouchard@gmail.com Received: by 10.49.133.39 with HTTP; Sat, 27 Apr 2013 11:22:38 -0700 (PDT) In-Reply-To: References: <170891005.EmXIrsICLC@rofl> Date: Sat, 27 Apr 2013 20:22:38 +0200 X-Google-Sender-Auth: TY3m4gTZj2KlbCUorsAJa1mgEfY Message-ID: To: Daniel Macedo Cc: Ferenc Kovacs , Julien Pauli , PHP Internals , Patrick Schaaf Content-Type: multipart/alternative; boundary=e89a8f6469dfc4f82604db5bbd06 Subject: Re: [PHP-DEV] Continued try blocks From: amaury@amaury.net (Amaury Bouchard) --e89a8f6469dfc4f82604db5bbd06 Content-Type: text/plain; charset=ISO-8859-1 2013/4/27 Daniel Macedo > Sorry but I disagree, I think you're approaching try-catch wrong. > > You shouldn't have a try-catch that *can* continue on the next line after > the throw. > What you should do is have decoupled code that handles _their own > exceptions_ nicely and either cleans up after itself else it rethrows the > exception/a new one. > > Any top level try-catch is supposed to be a control structure with one of > two chances: either lines 1-N go smoothly and no exceptions are thrown, or > Exception_X is thrown and you clean up on it's catch block... > It's an opinion, a software engineering choice. Not something that must be enforced by the language. It could be very useful in some situations, not all the time (as traits, for example). Ideally, every errors (in fact, any abnormal situation) should raise an exception, right? OK, but that doesn't mean that any abnormal situation should be able to break execution flow, with no other solution than writing more code. Also remember that you have the finally block. > Can you explain how the finally block can help in my example? --e89a8f6469dfc4f82604db5bbd06--