Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69613 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 46331 invoked from network); 17 Oct 2013 12:50:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Oct 2013 12:50:12 -0000 Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 217.114.215.10 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 217.114.215.10 mail.experimentalworks.net Received: from [217.114.215.10] ([217.114.215.10:52475] helo=mail.experimentalworks.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D7/47-12663-30DDF525 for ; Thu, 17 Oct 2013 08:50:11 -0400 Received: from [192.168.2.20] (ppp-88-217-72-240.dynamic.mnet-online.de [88.217.72.240]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: johannes@schlueters.de) by mail.experimentalworks.net (Postfix) with ESMTPSA id 84E9E401F7; Thu, 17 Oct 2013 14:50:21 +0200 (CEST) To: Joe Watkins Cc: internals@lists.php.net In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Date: Thu, 17 Oct 2013 14:49:59 +0200 Message-ID: <1382014199.3980.249.camel@guybrush> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Assertions From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) On Thu, 2013-10-17 at 08:25 +0100, Joe Watkins wrote: > Morning All, > > I'd like to draw some attention to how poor assertions are in PHP. > > The current assertion API is not usable in my opinion; it has a > considerable overhead, relies on eval(), and is generally poorly > implemented. I don't have a strong opinion on this, but mind that by being based on eval the assert expression can use features from a different version of PHP. Something like if (PHP_VERSION_ID >= 50300) { assert('foo\\bar::baz == 42'); } the new form if (PHP_VERSION_ID >= 50300) { assert foo\\bar::baz == 42; } would give a parse error on older versions. (Yes, I'm using 5.3 and <5.3 as example where the new form would fail anyways, feel free to use PHP_VERSION_ID >= 51200 and PHP 5.26.0 features) > > This means that assert("some code here") will pass assertion > causing no error, because strings are no longer treated as code, > because eval is evil(); > I think this is bad for migration of code. For one it is impossible to have a code base with asserts working in both versions. For two it silently leads to completely different behavior. Changing this needs some clever strategy allowing migration. johannes