Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68514 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 28560 invoked from network); 14 Aug 2013 11:44:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Aug 2013 11:44:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=krebs.seb@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=krebs.seb@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.175 as permitted sender) X-PHP-List-Original-Sender: krebs.seb@gmail.com X-Host-Fingerprint: 74.125.82.175 mail-we0-f175.google.com Received: from [74.125.82.175] ([74.125.82.175:64558] helo=mail-we0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EA/44-06453-9BD6B025 for ; Wed, 14 Aug 2013 07:44:58 -0400 Received: by mail-we0-f175.google.com with SMTP id q58so7613210wes.20 for ; Wed, 14 Aug 2013 04:44:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=k4XX57PEZWbDzxDnb03kIOIRFZAaXHpvD+CCZnXNiLI=; b=Zev7fdymEY+c0SVbZLb1HyBnzfCBHqlo6+XOWfMBVCn/IKA49cP+bQLNIlH/I2y5Wv iF5qOwkkct73dDgweIyHkn5/yD84M+DF1TmRDavRCw79Z+UMdIqZIUYMTcoccA2bbG6a B01HE+heifHv8ukLJJgyv/r21kS0PpAp8uP9FQ7keLr0/AEi2cFDig/U5HGM70aDq7ud +Cwzl9BFrMTQaZ0zJ56/jzccBKgE75mgn8atrou0kRjf0qI+1wiRrT/khz0fV4kCvNws D9M539/EObifRC4p5JRob9C2RL98dcw+Uvtn+CdDDa9ynesnvBm+LtSQMorKufTBYd6r s/Sw== X-Received: by 10.180.109.167 with SMTP id ht7mr5820406wib.45.1376480695251; Wed, 14 Aug 2013 04:44:55 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.5.9 with HTTP; Wed, 14 Aug 2013 04:44:15 -0700 (PDT) In-Reply-To: References: <520B4772.8090701@sugarcrm.com> Date: Wed, 14 Aug 2013 13:44:15 +0200 Message-ID: To: Anthony Ferrara Cc: Stas Malyshev , Julien Pauli , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=e89a8f3ba7e1e17bb304e3e6e248 Subject: Re: [PHP-DEV] [RFC] Constant Scalar Expressions From: krebs.seb@gmail.com (Sebastian Krebs) --e89a8f3ba7e1e17bb304e3e6e248 Content-Type: text/plain; charset=ISO-8859-1 Hi, Just asking: Does this cover only declarations, or every constant expression, for example $weeks = $secs / (60 * 60 * 24 * 7); becomes to the opcode-equivalent of $weeks = $secs / (604800); ? 2013/8/14 Anthony Ferrara > Stas, > > > On Wed, Aug 14, 2013 at 5:01 AM, Stas Malyshev >wrote: > > > Hi! > > > > >> https://wiki.php.net/rfc/const_scalar_expressions > > > > I like the idea, but absence of constant support makes this thing much > > less useful, as you can't do things like: > > > > public $angle = M_PI/2; > > > > I think this is one of the reasons this idea was never implemented - > > because without constant support you're limited to doing things that are > > quite obvious and trivial. > > > > Yeah, having constants in those expressions would be great. If only > constants in PHP were actually constant... > > But this win is really cheap (a trivial change to the parser), so I figured > it was worth proposing separately. If we want to add the opcode stream > later to do expressions for constant values, we can. This just gives us the > quick win today of allowing relatively trivial, but important expressions. > > The biggest wins I see are in power-of-2 math: > > class Foo { > const FLAG_1 = 1 << 0; > const FLAG_2 = 1 << 1; > const FLAG_3 = 1 << 2; > const FLAG_4 = 1 << 3; > const FLAG_5 = 1 << 4; > const FLAG_6 = 1 << 5; > const FLAG_7 = 1 << 6; > } > > And in other complex formulas where having the self-declaration adds > semantic meaning. > > Now, as far as if it's worth while making the change without constant > support, that's for each of us to decide. I think it is, but if you don't, > that's cool too. > > Thanks > > Anthony > -- github.com/KingCrunch --e89a8f3ba7e1e17bb304e3e6e248--