Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69674 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31283 invoked from network); 18 Oct 2013 12:27:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Oct 2013 12:27:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-we0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:56046] helo=mail-we0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7C/61-23638-12921625 for ; Fri, 18 Oct 2013 08:27:14 -0400 Received: by mail-we0-f170.google.com with SMTP id u57so3697663wes.29 for ; Fri, 18 Oct 2013 05:27:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=RRXpdyHcWxUU4WQd98svimvFTuwVff8rQG4RBOFX0YY=; b=MGfBK68enlXWAgDHspJkeKmLHkabAs195kPQ3DFfK8EG/NN7vbC8odEMfeZ+coVC3Y ocfstJzcJVcBS4aLdUam1bB60QQVbkxR0nEOlCT011SX+2XZElAY7DWMTcIdqgnskz7y D1IOUrsz5Z9BCBMIJSfUudTevVuIjiYzQP+5NYd7yzfBNeXjrT52A7I5abMlzbc6K8ph n5cJeD83lQ+Fj8HTcFz6XOV7uD3EQ2kNaymJEr577K7tLT8clNHdM0ieNeF5OuhQcnbB l1R+IlXuLRZNmtJNsWtrfQBXaf5I/moQx418qUywL32EQUoYwKjKqADNC1t67HfJirZ2 A5gg== X-Received: by 10.180.211.7 with SMTP id my7mr2226852wic.17.1382099230653; Fri, 18 Oct 2013 05:27:10 -0700 (PDT) Received: from [192.168.0.2] (cpc19-brig17-2-0-cust25.3-3.cable.virginmedia.com. [81.101.201.26]) by mx.google.com with ESMTPSA id bs15sm26568345wib.10.2013.10.18.05.27.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Oct 2013 05:27:09 -0700 (PDT) Message-ID: <52612910.5090900@gmail.com> Date: Fri, 18 Oct 2013 13:26:56 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 To: internals References: <525FC834.4060501@php.net> <1534105.bNC2os93J1@rofl> <525FDAC3.6060103@php.net> <52601C6A.6020408@php.net> <526059D2.5080109@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Assertions From: rowan.collins@gmail.com (Rowan Collins) On 18/10/2013 01:45, Marco Schuster wrote: > On Thu, Oct 17, 2013 at 11:42 PM, Rowan Collins wrote: >> The current implementation allows you to define a callback, and to choose >> whether assertions are fatal, which means that unit test frameworks and >> fancy-output wrappers can intercept assertions *without affecting other >> parts of the code*. The only way to do that with catch blocks would be to >> have an exception which didn't descend from Exception. > You could always throw a secondary exception from the catch-block. It's not so much a question of whether it would be *possible* to write code which handled such situations, as whether it is reasonable to *expect* people to do so: as soon as assert() started throwing exceptions, all code which uses assert() would have to be audited to see what catch blocks the AssertExceptions would fall into, and add extra boilerplate to explicitly re-throw them. I agree with J David to the extent that whatever behaviour assert() should have, it should be *distinct* from other types of error checking. Having assertions be caught by a catch(Exception) block reduces that distinction while increasing the BC break. Meanwhile, what is the actual case for catching the assertion in a code block rather than registering a failure callback? So far, it seems to be a case of "callbacks feel a bit old-fashioned" - the uses cases people have mentioned of Unit Tests and pretty debug output are both adequately covered by a simple callback. Is there a situation where you would, for instance, want to catch an AssertionException, do something, and then re-throw it to an outer block? -- Rowan Collins [IMSoP]