Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45641 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68224 invoked from network); 27 Sep 2009 14:40:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Sep 2009 14:40:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.94.239.5 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.94.239.5 jdi.jdi-ict.nl Received: from [82.94.239.5] ([82.94.239.5:49141] helo=jdi.jdi-ict.nl) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B8/A0-63857-E697FBA4 for ; Sun, 27 Sep 2009 10:40:47 -0400 Received: from localhost (localhost [127.0.0.1]) by jdi.jdi-ict.nl (8.13.8/8.13.8) with ESMTP id n8REeg1o003648; Sun, 27 Sep 2009 16:40:43 +0200 Date: Sun, 27 Sep 2009 09:40:42 -0500 (CDT) X-X-Sender: derick@kossu.ez.no To: jvlad cc: internals@lists.php.net In-Reply-To: Message-ID: References: <4ABEF474.3000208@warpmail.net> <5BC5C25BC5F2492DB1E9DEF1C9E322E2@pc> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [PHP-DEV] Bitwise Declaration of Flags From: derick@php.net (Derick Rethans) 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 -- http://derickrethans.nl | http://ezcomponents.org | http://xdebug.org twitter: @derickr