Re: [PATCH] Allow constant expressions

From: Date: Thu, 10 Apr 2003 08:50:16 +0000
Subject: Re: [PATCH] Allow constant expressions
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-834@lists.php.net to get a copy of this message
At 11:21 10/04/2003, Sterling Hughes wrote:
On Thu, 2003-04-10 at 02:59, Zeev Suraski wrote: I think there's one broken thing in this patch (I haven't tested it, so I could be wrong) - it removes some functionality that we did have in the past. static_scalar can no longer contain a constant (one that was defined with define()). That means that constant initializers for arrays, default arguments, etc - lose a big chunk of functionality. (again, I arrived at that conclusion by briefly going over the parser patch, if you took this into account and it does work - go ahead and commit it, it looks good). It does,kinda. Because I was doing folding the last patch adds a new type (const_sclar i believe, i'm becoming senile), which doesn't support define'd constants, etc. Normal functionality remains untouched.
Please look again, I think you're wrong: static_scalar: /* compile-time evaluated scalars */
                common_scalar           { $$ = $1; }
-       |       T_STRING                { zend_do_fetch_constant(&$$, NULL, &$1, ZEND_CT TSRMLS_CC); }
+       |       T_STRING                { zend_do_fold_constant(&$$, &$1 TSRMLS_CC); }
        |       '+' static_scalar       { $$ = $2; }
-       |       '-' static_scalar       { zval minus_one;  minus_one.type = IS_LONG; minus_one.value.lval = -1;  mul_function(&$2.u.constant, &$2.u.constant, &minus_one TSRMLS_CC);  $$ = $2; }
+       |       '-' static_scalar       { zval minus_one;  minus_one.type = IS_LONG; minus_one.value.lval = -1;  mul_function(&$2.u.constant, &$2.u.constant, &minus_one TSRMLS_CC);  $$ = $2; }
        |       T_ARRAY '(' static_array_pair_list ')' { $$ = $3; $$.u.constant.type = IS_CONSTANT_ARRAY; }
        |   class_or_namespace_constant { /* FIXME */ }
;
I personally think that's a reasonable 90%, and its nice to also have a compile time constant.
Not sure what you're talking about here :) Zeev

« previous php.internals (#834) next »