Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72031 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54538 invoked from network); 3 Feb 2014 01:51:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Feb 2014 01:51:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=pthreads@pthreads.org; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=pthreads@pthreads.org; sender-id=unknown Received-SPF: error (pb1.pair.com: domain pthreads.org from 74.125.82.172 cause and error) X-PHP-List-Original-Sender: pthreads@pthreads.org X-Host-Fingerprint: 74.125.82.172 mail-we0-f172.google.com Received: from [74.125.82.172] ([74.125.82.172:60683] helo=mail-we0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C2/D8-30967-C36FEE25 for ; Sun, 02 Feb 2014 20:51:56 -0500 Received: by mail-we0-f172.google.com with SMTP id p61so1615322wes.17 for ; Sun, 02 Feb 2014 17:51:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=p/O7dU7of8liHFCZzqQQAn11beHtyXNUsFL7OAu3Gus=; b=bq7GBRj7bx1NtP/tFcDvYwPuB9OAHP9agMCBgpJ0L5f9/yvp4xobB+kvSiHGbjtLBu kRgFG4BYFIpNqQH0WkC1AHXLdhfYFuxTxKyamkEWPX+DXPPLSj4+fh6LjnNWjnvA9dpl EblvZY4Erbfx/GA3IyCXKEr6rS7w8chRM8xMYopy2LXNM3mypyfQfF1tCyBbR7lWHohM texbt4mGS1ZYnbCVkCewmYR7NYWRCZ1U00BPP4vMUcUy0gNQv/ZtBDEGwRAq1HLMj5Jl 18S0KBFsvg1DTu5O/8o4NXhfXIZbp9Z9Ugrj/wc3SzeIqQWZox9ExuVYqihoZpaYw7IS oSgw== X-Gm-Message-State: ALoCoQlNsTUVt2nZ55iix7EBxFeO6sZP2iFCnq9gt+iThalUxRdlFnhE5cLwuxFWfLjQgxrSSPnb X-Received: by 10.180.108.130 with SMTP id hk2mr6921293wib.16.1391392313476; Sun, 02 Feb 2014 17:51:53 -0800 (PST) Received: from [192.168.1.3] (92.41.115.212.threembb.co.uk. [92.41.115.212]) by mx.google.com with ESMTPSA id j9sm39687569wjz.13.2014.02.02.17.51.51 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 02 Feb 2014 17:51:52 -0800 (PST) Message-ID: <52EEF636.7010505@pthreads.org> Date: Mon, 03 Feb 2014 01:51:50 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Stas Malyshev , PHP internals References: <52EE2B1D.7000307@pthreads.org> <52EEA7BE.4050500@sugarcrm.com> In-Reply-To: <52EEA7BE.4050500@sugarcrm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] RFC: expectations/assertions From: pthreads@pthreads.org (Joe Watkins) On 02/02/2014 08:17 PM, Stas Malyshev wrote: > Hi! > >> Still, there's no reason for us to have a crappy assertion api as part >> of the core just because there's a way around it(-ish) in user land. > I think there is some reason - if it can easily be done in userland, > with more flexibility and suitability for particular purposes of the > user, why put it in core? If it's such a common feature, make a PSR for > it and create reference implementation that everybody would be using. So > my question is - what having in core adds to it that can't be done as > easily in userland? > > Also, it essentially splits assert() into two completely independent > things one of them being regular function that you can call and another > being weird magic thing. Moreover, for the same assert there's now two > completely independent ways of controlling it - one is zend.assert and > another is assert_options/ASSERT_ACTIVE. E.g. compare: > > // This is controlled by zend.assert > assert($foo > 1, "Foo is too small"); > > // This is controlled by assert_options > $f = 'assert'; > $f($foo > 1, "Foo is too small"); > > This looks a bit strange for me. > > Also, assert() will throw exception if assert.bail = 1 and > assert.exception = 1, but only if the argument is not a string. If the > argument is a string no exception will be thrown. OTOH, if the argument > IS a string, assert will both throw exception *and* bail out, which is > not clear what is the purpose of that. > > I'm also feeling a bit uneasy with adding more and more special cases > for special names in the engine. Maybe we could create some more generic > facility that would not need to be one-off case for just one function? Well lets not forget that we already have an implementation as part of the core, so to argue that we don't require assert in the core is moot; we already have it. While you can avoid some overhead in userland, you cannot remove the overhead completely; a good assertion API should have no impact on production, none, it should require no boilerplate code to make sane use of it, at all, since it is meant to be a core feature. It would seem to create inconsistency, but only because it's compatible with legacy code asserting strings, if you are smart, you will not assert with strings and take advantage of the new implementation, if you are not, you will continue to assert strings and be unaffected by the new implementation ... that seems ideal to me, and Dmitry ... Cheers Joe