Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68542 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66359 invoked from network); 15 Aug 2013 23:57:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Aug 2013 23:57:26 -0000 Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 217.114.211.66 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 217.114.211.66 config.schlueters.de Received: from [217.114.211.66] ([217.114.211.66:33941] helo=config.schlueters.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F0/7B-06453-5EA6D025 for ; Thu, 15 Aug 2013 19:57:26 -0400 Received: from [192.168.2.20] (ppp-88-217-94-43.dynamic.mnet-online.de [88.217.94.43]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by config.schlueters.de (Postfix) with ESMTPSA id E0ED26CB2D; Fri, 16 Aug 2013 01:57:22 +0200 (CEST) To: Stas Malyshev Cc: Sara Golemon , Derick Rethans , Anthony Ferrara , Sebastian Krebs , Julien Pauli , "internals@lists.php.net" In-Reply-To: <520D6758.4050500@sugarcrm.com> References: <520B4772.8090701@sugarcrm.com> <520BBA89.1090208@sugarcrm.com> <520D6758.4050500@sugarcrm.com> Content-Type: text/plain; charset="UTF-8" Date: Fri, 16 Aug 2013 01:57:03 +0200 Message-ID: <1376611023.14536.245.camel@guybrush> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Constant Scalar Expressions From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) On Thu, 2013-08-15 at 16:42 -0700, Stas Malyshev wrote: > Hi! > > > Though obv, in reality we wouldn't use runkit_constant_add(), it'd be a > > new opcode which had the same effect. This is basically transparent to > > opcode caches, allows the constant to actually change based on runtime > > If the class definition can actually change at runtime, I think it'd > make it much harder for opcode caches since they can't any longer assume > class definition can't change at any random place in the code. > > But this is not the most tricky part. The most tricky part is this: > > > if(true) return; > class Foo { > const halfpie = M_PI/2; > } > > Now what happens if this is implemented as an opcode? We can't run any > opcodes past return statement, but Foo is expected to be defined here. note that we have this functionality already: $ php -r 'class A { const C = FOO; } define("FOO", 23); echo A::C;' 23 The first fetch will resolve that. If we add "constant scalar expression" this has to work for class constants, too. Else we add crazy new inconsistencies to the language. johannes