Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45639 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51475 invoked from network); 27 Sep 2009 10:44:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Sep 2009 10:44:00 -0000 Authentication-Results: pb1.pair.com smtp.mail=sv_forums@fmethod.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=sv_forums@fmethod.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fmethod.com from 69.16.228.148 cause and error) X-PHP-List-Original-Sender: sv_forums@fmethod.com X-Host-Fingerprint: 69.16.228.148 unknown Linux 2.4/2.6 Received: from [69.16.228.148] ([69.16.228.148:44996] helo=host.fmethod.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0A/A3-26789-0F14FBA4 for ; Sun, 27 Sep 2009 06:44:00 -0400 Received: from [83.228.56.37] (port=1402 helo=pc) by host.fmethod.com with esmtpa (Exim 4.69) (envelope-from ) id 1MrrET-00049t-85; Sun, 27 Sep 2009 05:43:57 -0500 Message-ID: <5BC5C25BC5F2492DB1E9DEF1C9E322E2@pc> To: "Clint Priest" , "PHP Developers Mailing List" References: <4ABEF474.3000208@warpmail.net> Date: Sun, 27 Sep 2009 13:43:51 +0300 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="ISO-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5843 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host.fmethod.com X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - fmethod.com Subject: Re: [PHP-DEV] Bitwise Declaration of Flags From: sv_forums@fmethod.com ("Stan Vassilev") > Are there any plans to allow bitwise declaration of flags? > > Example: > > class foo { > const FLAG_1 = 1; > const FLAG_2 = 2; > const FLAG_3 = 4; > > private $Flags = self::FLAG_1 | self::FLAG_3 > } 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; } } Regards, Stan Vassilev