Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45640 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66751 invoked from network); 27 Sep 2009 14:33:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Sep 2009 14:33:32 -0000 X-Host-Fingerprint: 85.21.236.169 xdmitri.static.corbina.ru Received: from [85.21.236.169] ([85.21.236.169:27957] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C4/50-63857-BB77FBA4 for ; Sun, 27 Sep 2009 10:33:31 -0400 Message-ID: To: internals@lists.php.net References: <4ABEF474.3000208@warpmail.net> <5BC5C25BC5F2492DB1E9DEF1C9E322E2@pc> Date: Sun, 27 Sep 2009 18:33:28 +0400 Lines: 42 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5843 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-RFC2646: Format=Flowed; Response X-Posted-By: 85.21.236.169 Subject: Re: [PHP-DEV] Bitwise Declaration of Flags From: dmda@yandex.ru ("jvlad") > Hi, > > 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; > } > } > Hi, ok, and could you please point out to the thing in self::FLAG_1 that is unresolveable at compile-time? To me it seems that nothing prevents from declaring constants based on the other constants. Since self is always resolveable, such declarantions can be allowed. > $this->flags = self::FLAG_1 | self::FLAG_3; this is not the best solution because it executes the statements each time you create an instance of foo class, while the class constant would be calculated only once at compile-time. just my 2c. jv