Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70282 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24647 invoked from network); 22 Nov 2013 13:10:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Nov 2013 13:10:00 -0000 Authentication-Results: pb1.pair.com smtp.mail=bobwei9@hotmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=bobwei9@hotmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain hotmail.com designates 65.55.111.161 as permitted sender) X-PHP-List-Original-Sender: bobwei9@hotmail.com X-Host-Fingerprint: 65.55.111.161 blu0-omc4-s22.blu0.hotmail.com Windows 2000 SP4, XP SP1 Received: from [65.55.111.161] ([65.55.111.161:20850] helo=blu0-omc4-s22.blu0.hotmail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6E/84-28674-6A75F825 for ; Fri, 22 Nov 2013 08:09:59 -0500 Received: from BLU0-SMTP52 ([65.55.111.137]) by blu0-omc4-s22.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 22 Nov 2013 05:09:56 -0800 X-TMN: [0wBbJMOftAhpKNvbgRRbIQO+fvvp5o/0] X-Originating-Email: [bobwei9@hotmail.com] Message-ID: Received: from bobweinandsimac.fritz.box ([83.99.63.185]) by BLU0-SMTP52.phx.gbl over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Fri, 22 Nov 2013 05:09:53 -0800 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 (Mac OS X Mail 7.0 \(1822\)) In-Reply-To: Date: Fri, 22 Nov 2013 14:09:50 +0100 CC: List PHP Mailing List , Tjerk Meesters Content-Transfer-Encoding: quoted-printable References: To: Yasuo Ohgaki X-Mailer: Apple Mail (2.1822) X-OriginalArrivalTime: 22 Nov 2013 13:09:54.0031 (UTC) FILETIME=[2277F7F0:01CEE784] Subject: Re: [PHP-DEV] [RFC] [VOTE] Constant scalar expressions From: bobwei9@hotmail.com (Bob Weinand) Am 22.11.2013 um 10:18 schrieb Yasuo Ohgaki : > On Fri, Nov 22, 2013 at 2:38 PM, Tjerk Meesters = wrote: >=20 >> [yohgaki@dev tmp]$ php bench.php >>> Time: 6.4104981422424 >>> Time: 7.7053151130676 20.198383060014% slower >>> Time: 8.022579908371 25.14752723358% slower >>> Time: 7.5032601356506 17.046444272519% slower >>> Time: 7.713919878006 20.332612331241% slower >>>=20 >>=20 >> This is way too much variation to be reliable. >>=20 >>=20 >=20 > VM was working while executing the script :p >=20 >=20 >> Actually, the test should be done against two separate builds: >> 1) build without patch >> 2) build with patch >>=20 >=20 > I agree. >=20 > Since the script includes loop overhead, pure difference is much = larger. >=20 > It's a small difference, but people are working remove unnecessary > memory indirection, etc for better performance. >=20 > We might be better to consider extending define(). >=20 > Regards, >=20 > -- > Yasuo Ohgaki > yohgaki@ohgaki.net Hi, I just wanted to note that it also implies default values in function = arguments and properties values upon initialization. That are things where you need that RFC (without polluting the current = namespace with constants). Compare: Old: const a =3D 10; define("b", a * 2); class name { public static $b =3D b; } With patch: const a =3D 10; class name { public static $b =3D a * 2; } I think the latter is much cleaner to write. Also the latter should be = faster: no extra function call. See also: = https://wiki.php.net/rfc/const_scalar_exprs#class_property_declarations = (and following two examples) Bob