Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83301 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97473 invoked from network); 20 Feb 2015 14:09:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Feb 2015 14:09:58 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.172 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 74.125.82.172 mail-we0-f172.google.com Received: from [74.125.82.172] ([74.125.82.172:45441] helo=mail-we0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 62/B6-54878-F1047E45 for ; Fri, 20 Feb 2015 09:09:36 -0500 Received: by wesw62 with SMTP id w62so5770390wes.12 for ; Fri, 20 Feb 2015 06:09:33 -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=v/6RnuoGirVmS42H6ZCQ9ucuejmEIm0riNR+WtmBWWA=; b=WnAawX/wOjj0x4rWdYfk3sjPC7neq9ztYpLDo0NOfuo2XYrbqEyVtZrvU8lEdVIDoG U2wC30HN+5mq8ax45aXgGB2zgkKIa0NjW3AofU74uqzuh2z1zk594kExrm4IymRp5+X6 yeSlVEDFivB5pJPjm2xcZHI0LsRXS1Q4k49TLi/MmzBm3+JB2PpkDg/ZQ/p4/w93BzjO 81/0+YBSbxN53RvPScvjMNxpPD36PZeW49nQ2hXySOFMJKb5f6Se+CYxniSqvkk6JBGc 7Pw+EDtvkhkW2E2cr89ANxWhk3GFs/vFDYDzqWa2cxENtgAdk3JsE+kzVJoTmLQ/tmUr FN8w== MIME-Version: 1.0 X-Received: by 10.180.109.33 with SMTP id hp1mr5973749wib.33.1424441373023; Fri, 20 Feb 2015 06:09:33 -0800 (PST) Received: by 10.27.10.168 with HTTP; Fri, 20 Feb 2015 06:09:32 -0800 (PST) In-Reply-To: <54E73E70.5020403@googlemail.com> References: <54E5F77D.9090406@fischer.name> <54E6F48A.9040906@fischer.name> <54E72FE7.9030803@googlemail.com> <54E7312D.9090404@googlemail.com> <54E73E70.5020403@googlemail.com> Date: Fri, 20 Feb 2015 15:09:32 +0100 Message-ID: To: Crypto Compress Cc: PHP Developers Mailing List Content-Type: multipart/alternative; boundary=e89a8f3ba35d0ae6e0050f859ae4 Subject: Re: [PHP-DEV] [VOTE] Expectations From: nikita.ppv@gmail.com (Nikita Popov) --e89a8f3ba35d0ae6e0050f859ae4 Content-Type: text/plain; charset=UTF-8 On Fri, Feb 20, 2015 at 3:02 PM, Crypto Compress < cryptocompress@googlemail.com> wrote: > > AssertionExceptions are not intended to be caught, they are intended to >> be seen, in a specific environment. >> > > Joe, your argumentation is around how (not) to use exceptions. I can see > your point and it's valid. > My point is about not to implement exceptions at all. > > If exceptions are not intended to be caught, they don't need to be thrown > (even if the context is different). > If exceptions are not thrown and not caught, we can use "error" in dev and > some easing severity (warning, zero cost nothing) in prod. > > Freely adapted from Murphy: If assertion exception can be catched, it will > be even in production. > The point behind AssertionException is that a) It will leave the scope where with the failed assertion immediately. A warning would continue running the code, even though some precondition is violated, which doesn't make sense. b) It can still be gracefully handled (unlike a fatal error). E.g. the unit testing framework can catch it, so you can continue running all your tests even if one causes an assertion failure. When Joe says "not intended to be caught" this is referring to "normal" code. Catching them at the top-level still makes sense, e.g. for the unit testing case mentioned or even just to print a nice error message with extra information. Using an exception instead of a fatal error also means that things like "finally" will still run, so your code can still release locks etc even if an assertion failure occurred. Nikita --e89a8f3ba35d0ae6e0050f859ae4--