Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70273 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87116 invoked from network); 22 Nov 2013 01:30:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Nov 2013 01:30:48 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.179 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.217.179 mail-lb0-f179.google.com Received: from [209.85.217.179] ([209.85.217.179:52513] helo=mail-lb0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A1/22-09639-6C3BE825 for ; Thu, 21 Nov 2013 20:30:47 -0500 Received: by mail-lb0-f179.google.com with SMTP id l4so429948lbv.24 for ; Thu, 21 Nov 2013 17:30:44 -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=IQ2J4SLJDZkFqr6y3d/gh240RapvuJEzLfcAvwkcmcs=; b=qOF1OkHYUcsaZ5E3JcVW6bzPUyg7Bn/UY7Gq9/AmYImuqJdyH9K5bGb2JGn/U7UfI/ ZmPKeTevLRDoehuSfHrWq2qbrPjX55uIfaHrsCxSpBOh0Ned0hU2c2/3FQdLyQN47GY9 EzW8ML0KTxyR1qchSkBPIMUQKG0jQMKbl01nsBZh7kmS/kpcIeKjo42/ahlVhI0csjcX kZJCMQlG20UQLUM6hXpMiD/P9Qklx2mmzDvr7bimbz0NWn3m3w3zjvfHPVr3Ve/dw2GQ 4IX5CwUy8CfQlkAiL6m15mRNzY+P/RfYzDuUqVcWfhsFEw7L77g5HUwkbbm4SsYxFxq2 dFEg== X-Received: by 10.112.89.42 with SMTP id bl10mr6158824lbb.18.1385083844199; Thu, 21 Nov 2013 17:30:44 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.154.201 with HTTP; Thu, 21 Nov 2013 17:30:04 -0800 (PST) In-Reply-To: References: Date: Fri, 22 Nov 2013 10:30:04 +0900 X-Google-Sender-Auth: -9gwqjD9nq_PvhT-IuCJVotkXic Message-ID: To: Bob Weinand Cc: List PHP Mailing List Content-Type: multipart/alternative; boundary=001a11c374a684917e04ebb9f68e Subject: Re: [PHP-DEV] [RFC] [VOTE] Constant scalar expressions From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a11c374a684917e04ebb9f68e Content-Type: text/plain; charset=UTF-8 Hi all, On Fri, Nov 22, 2013 at 10:19 AM, Yasuo Ohgaki wrote: > On Fri, Nov 22, 2013 at 10:09 AM, Yasuo Ohgaki wrote: > >> Anyway, constant variables are useful for VM/op code optimization. >> >> include('foo.php'); // const a = 123; >> const b = a; >> >> is allowed currently. We may restrict this behavior only to the same file, >> so that VM/op code optimization can be done. >> >> Currently, no expression is allowed with 'const'. Defining 'const' using >> another constant with the same value is useless. It's a bad coding >> practice >> in many case, I suppose. >> >> I understand use cases of scalar expressions with constants, but I'm >> concerned >> loosing door for further optimizations. (e.g. $x = $x + 123 is faster >> than $x = $x + a, >> where a is 123 in constant var hash) >> >> We may be better to restrict expressions with constants only to the same >> file >> even if we loose some benefits/flexibility in user code. >> >> Is this discussed? >> > > I voted 'yes', but I change my mind. Sorry. > If the RFC leaves door for constant optimization, I'll vote 'yes'. > Constant look up is not a simple hash look up. > One more additional note why I decided to vote 'no' for this. We already have dynamic constant via define(). We can even use function return values with define(). I prefer 'const' to be a static for better performance, since we have dynamic constant by define() already. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a11c374a684917e04ebb9f68e--