Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69650 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14827 invoked from network); 17 Oct 2013 18:06:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Oct 2013 18:06:07 -0000 Authentication-Results: pb1.pair.com header.from=jdavidlists@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=jdavidlists@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.170 as permitted sender) X-PHP-List-Original-Sender: jdavidlists@gmail.com X-Host-Fingerprint: 209.85.223.170 mail-ie0-f170.google.com Received: from [209.85.223.170] ([209.85.223.170:45593] helo=mail-ie0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5A/55-12663-E0720625 for ; Thu, 17 Oct 2013 14:06:07 -0400 Received: by mail-ie0-f170.google.com with SMTP id at1so4635038iec.1 for ; Thu, 17 Oct 2013 11:06:04 -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; bh=KntO5CMn11wZHpWYmVOFZ5Lewd30Edyo0kDlJxXAqLs=; b=vQa/Cpv/DOUKXSUtN7oyMYc2yA1+oTNoH7i8s7X4/bjSmwa51HG0/xW+l27P+UK46m 6X/iGHm1lM+xqEhSh0cJ2yM5KMQnEk7kypkzNrmMQeLXSIvnb3t6XHTLK7S9A20iCth+ j8H4H/TmoVvQf1I7RA/scYerg62e/EDP3OfjntPAJT6dheAj6+TLcM87yKBb6lYWMEHQ p958bukp8SwYhBvSxDYlGkk3qbgBQXYG5bbNFkLODk4xDTW3gAQLfLBSPwQsXp9uENHY qMRU9ATM4qz4crMinMXrC3I+PVYrPVu4nsA8x8fh8uFU2Uy8VM1aNhpZtLn4BynDdRvf VeRw== MIME-Version: 1.0 X-Received: by 10.43.80.6 with SMTP id zs6mr6293704icb.33.1382033163842; Thu, 17 Oct 2013 11:06:03 -0700 (PDT) Sender: jdavidlists@gmail.com Received: by 10.43.180.131 with HTTP; Thu, 17 Oct 2013 11:06:03 -0700 (PDT) In-Reply-To: References: <525FC834.4060501@php.net> <1534105.bNC2os93J1@rofl> <525FDAC3.6060103@php.net> Date: Thu, 17 Oct 2013 14:06:03 -0400 X-Google-Sender-Auth: K73_ngz6pZiqmj7Vpf6-CbFXOyE Message-ID: To: Nikita Popov Cc: Joe Watkins , PHP internals , Michael Wallner Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Assertions From: j.david.lists@gmail.com (J David) On Thu, Oct 17, 2013 at 1:33 PM, Nikita Popov wrote: > Similarly, showing a friendly debugging page when an assertion fails does > not seem to go against your idea of assertions. You may be using asserts to test much too complicated concepts. Assertions are a *very* low-level feature. The classic example of an assert is to check that expectations are valid in some function that gets called in a loop 20,000,000 times and takes 6 minutes to run if you check the conditions and 3 seconds if you don't. If you are using assert to check that the session data is valid or that the MySQL connection is valid or something, that's not good. If there's an error message, it wasn't an assertion. If it's recoverable, it wasn't an assertion. > It just changes the > presentation form to simplify debugging the cause by specifying additional > information that is known to the framework (but not to the assertion > itself). > >> >> Why do we need a new way to throw an exception? >> >> Why do we need to mess up another tool that has a different purpose to do >> it? >> >> What's wrong with writing the three-line function one time to get the >> behavior you want? > > > Those questions have a very simple answer: You can't disable code throwing > exceptions ;) Assertions can be disabled. No, the code that throws "assertion exceptions" can be disabled. The code that catches them cannot. The value that assertions provide is the independent error handling channel. If you do not want the value that assertions provide, don't use them. If you want to make that error handling channel more robust and useful, go nuts, that would be great. If you want disable-able exception checks that can be skipped based on a global setting, and for some reason testing the global setting before testing the condition and throwing the exception is offensive to you, find a good name for this new feature and propose that. But please don't screw up existing code for people that use assertions properly by redefining them as exceptions. The behavior you're describing is trivial to implement at the user level, and it's still not clear why it belongs in the language core or why it needs to alter other, different, existing behavior. Thanks!