Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45642 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10437 invoked from network); 27 Sep 2009 23:18:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Sep 2009 23:18:53 -0000 Authentication-Results: pb1.pair.com header.from=cpriest@warpmail.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=cpriest@warpmail.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain warpmail.net does not designate 67.200.52.70 as permitted sender) X-PHP-List-Original-Sender: cpriest@warpmail.net X-Host-Fingerprint: 67.200.52.70 mail.omnisync.net Received: from [67.200.52.70] ([67.200.52.70:46823] helo=mail.omnisync.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 90/C0-06611-BD2FFBA4 for ; Sun, 27 Sep 2009 19:18:53 -0400 Message-ID: <4ABFF2DC.6060806@warpmail.net> Date: Sun, 27 Sep 2009 18:18:52 -0500 User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: Derick Rethans CC: jvlad , internals@lists.php.net References: <4ABEF474.3000208@warpmail.net> <5BC5C25BC5F2492DB1E9DEF1C9E322E2@pc> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Bitwise Declaration of Flags From: cpriest@warpmail.net (Clint Priest) Don't you mean it's NOT valid syntax? Derick Rethans wrote: > On Sun, 27 Sep 2009, jvlad wrote: > > >>> This is not allowed since declaration values should be resolvable at >>> compile time. I.e. they can not be an expression, but only a value >>> literal. >>> >>> While technically expression folding is possible, it's not >>> implemented in any part of the PHP engine (AFAIK), and I don't think >>> it's planned any time soon. >>> >>> To do what you want, initialize the value in the constructor: >>> >>> class foo { >>> ... >>> private $flags; >>> >>> function __construct() >>> { >>> $this->flags = self::FLAG_1 | self::FLAG_3; >>> } >>> } >>> >>> >> ok, and could you please point out to the thing in self::FLAG_1 that >> is unresolveable at compile-time? >> > > The following is also valid syntax: > > class foo { > private $Flags = self::FLAG_1 | self::FLAG_3 > > const FLAG_1 = 1; > const FLAG_2 = 2; > const FLAG_3 = 4; > } > > When the compiler hits self::FLAG_1 here, it's not yet defined. > > Derick > >