Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68515 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32904 invoked from network); 14 Aug 2013 12:39:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Aug 2013 12:39:42 -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.42 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.212.42 mail-vb0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:47647] helo=mail-vb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 15/F4-06453-D8A7B025 for ; Wed, 14 Aug 2013 08:39:41 -0400 Received: by mail-vb0-f42.google.com with SMTP id e12so3628209vbg.15 for ; Wed, 14 Aug 2013 05:39:39 -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=S+GvUWfmURzq8cX2/iq+KX1dkhWgyrM6CL7oubMlwAQ=; b=cRhcz6a1m8tabVH5LgxQJVML4YYN1d5XIGOEpsult9p/dOCrpLVHKxX6ssktHC3cQV 3gtdUjMWxplHTK8yfb6wAmOzaa3nujZ/pVO15c7pSYXLwydHgyd9XlBbMYGkZmJ36TBt AAv9DHFFs23Pfb3oa1KSX2yITFfPfg9eCQoGDGkBsdNa4N62pHojGxq9aaWPNbollnNx kpC2h6UiQkkZ950mlNeGmp0+4l0Z5ZRCJK5LmieaXh068cQf50+J8HpBpObAtsK7PD7d u8vaL0GF54Fm6Ywd0tjDne/CPfHi8TbqtRyd0MRgBQ4ygzGW81+u9582r9VN6XRqZJ37 2jWg== MIME-Version: 1.0 X-Received: by 10.52.230.102 with SMTP id sx6mr7609693vdc.15.1376483978950; Wed, 14 Aug 2013 05:39:38 -0700 (PDT) Received: by 10.58.94.201 with HTTP; Wed, 14 Aug 2013 05:39:38 -0700 (PDT) In-Reply-To: References: <520B4772.8090701@sugarcrm.com> Date: Wed, 14 Aug 2013 08:39:38 -0400 Message-ID: To: Sebastian Krebs Cc: Stas Malyshev , Julien Pauli , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e0111ae349ad05d04e3e7a669 Subject: Re: [PHP-DEV] [RFC] Constant Scalar Expressions From: ircmaxell@gmail.com (Anthony Ferrara) --089e0111ae349ad05d04e3e7a669 Content-Type: text/plain; charset=ISO-8859-1 Sebastian, On Wed, Aug 14, 2013 at 7:44 AM, Sebastian Krebs wrote: > 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); > > ? > Currently, only places that use the static_scalar parser definition will use this: http://lxr.php.net/xref/PHP_TRUNK/Zend/zend_language_parser.y#945 So today that's constants (using const keyword), class constants, class properties, function parameter values and declare statements. To do the other part would likely need to happen in the compiler itself (look for all opcodes of type _SPEC_CONST_CONST, and then optimize those away). I will experiment a bit, but my gut tells me it will result in a lot of parser or compiler complexity to attempt to do that (for which there will be so little gain, as the runtime performance is already quite fast)... At which point the complexity isn't worth it. Anthony --089e0111ae349ad05d04e3e7a669--