Re: [PATCH] Allow constant expressions

From: Date: Tue, 08 Apr 2003 10:37:04 +0000
Subject: Re: [PATCH] Allow constant expressions
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-785@lists.php.net to get a copy of this message
Nice patch, but one problem - it allows users to use constants as a part of those expressions... Since the values of those are not known until compile time, we have an issue there. Technically we can disallow such constants from being used in those expressions, but I'm not sure how well we can explain this (you can use constants, but not in expressions?) I don't know, maybe it's an ok thing to say. Zeev At 04:06 08/04/2003, Sterling Hughes wrote:
Hi, The attached patch allows constant expressions within class variables and constants. I came into this problem when I wanted the following sequence: class foo {
    const A = 1<<0;
    const B = 1<<1;
    const C = 1<<2;
} And the current parser doesn't allow such rules. I therefore added the attached patch which allows operators to be used on constants within these expressions (and also within array declarations). This is achieved by folding statements such as '1<<0' into their equivalent values at compile time. The following operators are supported: << >> | & + - * / . % ^ ~ xor Please review it, and let me know if its ok to commit. :) -Sterling -- "People can have the Model T in any colour -- so long as it's black."
    - Henry Ford
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.internals (#785) next »