Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83403 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45598 invoked from network); 21 Feb 2015 17:06:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Feb 2015 17:06:19 -0000 Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.41 as permitted sender) X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 209.85.216.41 mail-qa0-f41.google.com Received: from [209.85.216.41] ([209.85.216.41:46631] helo=mail-qa0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B7/6B-08895-A0BB8E45 for ; Sat, 21 Feb 2015 12:06:18 -0500 Received: by mail-qa0-f41.google.com with SMTP id x12so16864960qac.0 for ; Sat, 21 Feb 2015 09:06:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=uMEyMIBQ6F/x85TKuQVxqgqVLj4mKt8AdcbPplxyGX8=; b=vcxxnYUbbuhxXv3jkA5X1wt5HnT7JdxFLd5VeIriRXXpt/GRM/AK2WfoYMJvKcmjnd w/yL/daNPHhNctthJNZfku1KegDRm/BduGIseruBwKT/ygJAzE51449UP8tYHCCNj9fX HM6WWb8uiTOpguxrY8FdDRzPk0d/jBCdEs0/ug3Wo2AZCWXbnWpxi9AbiJcEwBKTBvu/ fzO9eWqAHSHLnDcUYaMOC+ERJDs0jMRy8Vndi2z9Ag9N6NJjgbAuXusWreJ1JuaeOPmf 9ZcpboR+qRpNlILf5sNmMtboFG9QYVPY39km+Hb4bAOiEMoXm5REKExqbxAKSuZwwfZb +rCQ== MIME-Version: 1.0 X-Received: by 10.229.19.68 with SMTP id z4mr7683144qca.14.1424538375878; Sat, 21 Feb 2015 09:06:15 -0800 (PST) Received: by 10.96.39.195 with HTTP; Sat, 21 Feb 2015 09:06:15 -0800 (PST) Received: by 10.96.39.195 with HTTP; Sat, 21 Feb 2015 09:06:15 -0800 (PST) In-Reply-To: References: <54E12349.7070806@gmail.com> <16.9B.05176.AE1C1E45@pb1.pair.com> <54E1C993.1070609@gmail.com> <37.20.01961.31113E45@pb1.pair.com> <54E32CAA.5030600@gmail.com> <54E4FAC2.7060200@gmail.com> <47.89.25547.DD007E45@pb1.pair.com> Date: Sat, 21 Feb 2015 09:06:15 -0800 Message-ID: To: Tony Marston Cc: PHP internals Content-Type: multipart/alternative; boundary=001a11343a4cdcfd5a050f9c2f82 Subject: Re: [PHP-DEV] [RFC] Exceptions in the engine From: pierre.php@gmail.com (Pierre Joye) --001a11343a4cdcfd5a050f9c2f82 Content-Type: text/plain; charset=UTF-8 On Feb 21, 2015 2:08 AM, "Tony Marston" wrote: > > ""Nikita Nefedov"" wrote in message news:op.xuco5eutc9evq2@nikita-pc... > >> >> On Fri, 20 Feb 2015 12:39:33 +0300, Tony Marston wrote: >>> >>> >>> I disagree. Exceptions were originally invented to solve the semipredicate problem which only exists with procedural functions, not object methods. Many OO purists would like exceptions to be thrown everywhere, but this would present a huge BC break. If it were possible get these functions to throw an exception ONLY when they are included in a try ... catch block then this would not break BC at all. >>> >> >> Tony, first of all - this still breaks BC, because exception is being thrown in a place where it used not to be... > > > I disagree. The following function calls would not throw exceptions > fopen(...); > fwrite(...); > fclose(...); > > while the following code would: > try { > fopen(...); > fwrite(...); > fclose(...); > } catch (....) { > > .... > } > >> When some function's result heavily depends on the context it makes said function much harder to reason about. And creates mental overhead for those who'll have to read the code with this function. >> >> And again, if you need exceptions for fopen please consider using SplFileObject. > > > For file usage, yes. But are there any other procedural functions without an Spl* alternative which would benefit from this technique? Expected failures should not raise exception. For example, IOs are expected to fail (be network, filesystem etc), I would really not be in favor of adding exceptions for similar cases. This is a normal control flow. --001a11343a4cdcfd5a050f9c2f82--