Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70276 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99445 invoked from network); 22 Nov 2013 05:12:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Nov 2013 05:12:10 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.52 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.215.52 mail-la0-f52.google.com Received: from [209.85.215.52] ([209.85.215.52:44461] helo=mail-la0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8F/B0-28674-8A7EE825 for ; Fri, 22 Nov 2013 00:12:09 -0500 Received: by mail-la0-f52.google.com with SMTP id ev20so555272lab.11 for ; Thu, 21 Nov 2013 21:12:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=plp821EHDUA/WVetTB7jUIxrSCUe2KNOsr5CyaUSheA=; b=bpZfsjKV4UL2hKDsm6qoNlwHTh8PTGaWwaJyW31GYIV67FgW0eGlK/tLj7KXhYWxxO RmOaXKhmDGvr5m3+yBapamTZvDEc1r0ivMQVAZwkaxgYNVOTm40JcO9KgfuTsEEycS8u iHrcxDm0g8D4CrJSgtTOkt+1XVnuz6TCJ3ENaTIc9I+uGxHkwPyQKHzugGu2YE+YOCGH r85dWIZNZewp/pM7fK1CrSAPli5jGke9m6/KtCdcpv1pf0LnhGtQWrYdX6v7bmbe8HJb Q+Co7bDK5DVSyV6nd6dE+3AAImR2Lwpl6TVw/tDNLpr98PTolWKzs0tBnuzP7TlTa0Z6 Z5nA== X-Received: by 10.112.130.37 with SMTP id ob5mr19113lbb.35.1385097125566; Thu, 21 Nov 2013 21:12:05 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.154.201 with HTTP; Thu, 21 Nov 2013 21:11:25 -0800 (PST) In-Reply-To: References: Date: Fri, 22 Nov 2013 14:11:25 +0900 X-Google-Sender-Auth: EpqF0nBbia00wCODQrxK68kW2Bc Message-ID: To: Tjerk Meesters Cc: Bob Weinand , List PHP Mailing List Content-Type: multipart/alternative; boundary=047d7b3432b6261d6804ebbd0ecc Subject: Re: [PHP-DEV] [RFC] [VOTE] Constant scalar expressions From: yohgaki@ohgaki.net (Yasuo Ohgaki) --047d7b3432b6261d6804ebbd0ecc Content-Type: text/plain; charset=UTF-8 Hi Tjerk, On Fri, Nov 22, 2013 at 1:34 PM, Tjerk Meesters wrote: > Yes, of course that's all possible, because define() is just a function > and therefore the normal assignment rules apply. However, you didn't > mention the biggest drawback to such an approach, which is that it creates > *global* constants; there's no way to namespace them. > What was the reason why we don't have name space for define()? >> I prefer 'const' to be a static for better performance, since >> we have dynamic constant by define() already. >> > > Perhaps we'd have to consider how much performance is impacted on existing > code, e.g. > > class A > { > const B = 123; > } > > How much slower would that become if this RFC is accepted, cached or > otherwise? > I made a script to experiment. I have background job running on this machine, so I don't get stable result now, but embedding value is constantly faster. [yohgaki@dev tmp]$ php bench.php Time: 6.4675929546356 Time: 7.4527719020844 15.232544075653% slower Time: 7.4178550243378 14.69266968975% slower Time: 8.1120491027832 25.426092205894% slower Time: 7.4948840141296 15.883669035753% slower [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 [yohgaki@dev tmp]$ cat bench.php -- Yasuo Ohgaki yohgaki@ohgaki.net --047d7b3432b6261d6804ebbd0ecc--