Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68545 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78527 invoked from network); 16 Aug 2013 03:42:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Aug 2013 03:42:17 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 108.166.43.115 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 108.166.43.115 smtp115.ord1c.emailsrvr.com Linux 2.6 Received: from [108.166.43.115] ([108.166.43.115:46776] helo=smtp115.ord1c.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 98/DD-06453-99F9D025 for ; Thu, 15 Aug 2013 23:42:17 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp7.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id 3DAB91B8111; Thu, 15 Aug 2013 23:42:14 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp7.relay.ord1c.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 77C911B810E; Thu, 15 Aug 2013 23:42:13 -0400 (EDT) Message-ID: <520D9F94.9010803@sugarcrm.com> Date: Thu, 15 Aug 2013 20:42:12 -0700 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: =?UTF-8?B?Sm9oYW5uZXMgU2NobMO8dGVy?= CC: Sara Golemon , Derick Rethans , Anthony Ferrara , Sebastian Krebs , Julien Pauli , "internals@lists.php.net" References: <520B4772.8090701@sugarcrm.com> <520BBA89.1090208@sugarcrm.com> <520D6758.4050500@sugarcrm.com> <1376611023.14536.245.camel@guybrush> In-Reply-To: <1376611023.14536.245.camel@guybrush> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Constant Scalar Expressions From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > 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. This is true, but what happens is that "FOO" is stored and then resolved on fetch with direct lookup. Now, if C = M_PI/2, what would we store? We could theoretically store string "M_PI/2" and somehow "evaluate" it, or we could even translate: class A { const C = M_PI/2; } to: class A { const C = __definition_of_A_C; } function __define_A_C() { define(__definition_of_A_C, M_PI/2); } and when we encounter __definition_of_A_C for the first time we run __define_A_C() and take the value of __definition_of_A_C - but I imaging that would seriously complicate the code, especially if we think about how to handle exceptional situations there... -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227