Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68510 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19654 invoked from network); 14 Aug 2013 10:44:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Aug 2013 10:44:49 -0000 Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.48 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.212.48 mail-vb0-f48.google.com Received: from [209.85.212.48] ([209.85.212.48:57065] helo=mail-vb0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 01/92-06453-1AF5B025 for ; Wed, 14 Aug 2013 06:44:49 -0400 Received: by mail-vb0-f48.google.com with SMTP id w16so7374760vbf.21 for ; Wed, 14 Aug 2013 03:44:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=e01QHJZg/f178ynqcbfnX5lj2RnQM6fA8sLSnd3vzK4=; b=Pl/o6oRRGfqo1l65CZy8dnOgP3xOTtAcAIIO6Y03WBHswdWpUYimGujl3qqrTKycep IgBC4+yVBDnf+j9XfjI3D95wTu6dPz3zadZCI20+VSci/gd7L+vkQ7cxxehRCv6MNCmE /QqNZkBNSTy4GlGkB1bG8OMCG4Y/5KfWWDSM4A6QhCMlbRnO2PsK97HEdkN2jfr2PIYO DTHSKDpgmdhh7qHztapaYKBB2cMestxdhaKBufD2/2Xim8RUc8RxchYOm0oiL/ssxnQf Ic7ZuUO6+pwkk7yCT7NVeWXI9KZTYfsFFxC/YCNWFusxWRTHL8A2Jmqk0B5e03c4yiko j49w== MIME-Version: 1.0 X-Received: by 10.58.127.202 with SMTP id ni10mr163762veb.27.1376477086604; Wed, 14 Aug 2013 03:44:46 -0700 (PDT) Received: by 10.58.94.201 with HTTP; Wed, 14 Aug 2013 03:44:46 -0700 (PDT) In-Reply-To: <520B4772.8090701@sugarcrm.com> References: <520B4772.8090701@sugarcrm.com> Date: Wed, 14 Aug 2013 06:44:46 -0400 Message-ID: To: Stas Malyshev Cc: Julien Pauli , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=047d7b5d870fc9e67704e3e60b03 Subject: Re: [PHP-DEV] [RFC] Constant Scalar Expressions From: ircmaxell@gmail.com (Anthony Ferrara) --047d7b5d870fc9e67704e3e60b03 Content-Type: text/plain; charset=ISO-8859-1 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 --047d7b5d870fc9e67704e3e60b03--