Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69638 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93628 invoked from network); 17 Oct 2013 16:06:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Oct 2013 16:06:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=jdavidlists@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=jdavidlists@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.171 as permitted sender) X-PHP-List-Original-Sender: jdavidlists@gmail.com X-Host-Fingerprint: 209.85.223.171 mail-ie0-f171.google.com Received: from [209.85.223.171] ([209.85.223.171:56380] helo=mail-ie0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F7/11-12663-71B00625 for ; Thu, 17 Oct 2013 12:06:47 -0400 Received: by mail-ie0-f171.google.com with SMTP id tp5so4369630ieb.30 for ; Thu, 17 Oct 2013 09:06:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=jiBSR8MTUQBaKBdiD14aITdwtEWY4Qma/wO6jEw9TmM=; b=c7E2+lCP7HwRDDyLxThj1zyv3NR3kyRwlxJMw6XagM+PQ9/v3UgD/gAdnXxWfzIwis 4zhxixuaGiTu6jx/8KDvQ3J6/qWdKJUQzvCvDsaUUanUsFEfm3JZCtuCOcVtpSiSRS1L +IPBOMUEOd+H4iQbhhlDjfz0Sf5Zaa2q/WUr9KfN8hw+yr8w7mHxA8Dnq+oN9xf97cYr urIkfYF526Sys2oVyzF2KqTJaGQLBC/ECN7cZyErEF4V5B6M8sfn2ffShkSmw9WRXqWT YmAGUUtYw1AGXVZKA/Y1CLTOrwIxZN4n5FNPRwPVNfQ6fJj3k4BCrW6wAe3RPNjjFrki CNRA== MIME-Version: 1.0 X-Received: by 10.43.161.65 with SMTP id mf1mr928950icc.66.1382026000114; Thu, 17 Oct 2013 09:06:40 -0700 (PDT) Sender: jdavidlists@gmail.com Received: by 10.43.180.131 with HTTP; Thu, 17 Oct 2013 09:06:40 -0700 (PDT) In-Reply-To: References: <525FC834.4060501@php.net> <1534105.bNC2os93J1@rofl> <525FDAC3.6060103@php.net> Date: Thu, 17 Oct 2013 12:06:40 -0400 X-Google-Sender-Auth: phlb6_uDUtW9eP8fpkiKrKM2br0 Message-ID: To: Nikita Popov Cc: Joe Watkins , PHP internals , Michael Wallner Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Assertions From: j.david.lists@gmail.com (J David) On Thu, Oct 17, 2013 at 11:51 AM, Nikita Popov wrote= : > Nobody is arguing that assertions should be used as a control-flow > structure. It's still most useful to implement them as exceptions. Apart > from being a lot better integrated than fatal errors (in particular they > have such fancy things like stacktraces...) exceptions can also be > gracefully handled where necessary. If it is useful to handle an assertion, then it wasn't an assertion. The minute you talk about "handling" assertions they become a control flow structure and cease to be assertions. > PHPUnit will catch the exception and tell you that an assertion failed, b= ut it will still be able to continue running the rest of the testsuite. > A framework (or front controller in general) can easily catch the excepti= on at the top level and display an appropriate debugging page (rather than = doing ugly register_shutdown_function hacks that are necessary to have even= remotely graceful handling of fatals). > A deamon or server will be able to process further requests, even if one = particular had an assertion failure. Those are three great examples of how assertions are frequently misused. There are *many* cases where assertions are not useful. That means use a different tool in those cases (like an exception), not that assertions should be made into shorthand for exception throwing. That functionality is fine to have, just call it something else. Thanks!