Re: [ZEND-ENGINE-CVS] cvs: Zend / zend_operators.c

From: Date: Sun, 14 Jul 2002 15:30:58 +0000
Subject: Re: [ZEND-ENGINE-CVS] cvs: Zend / zend_operators.c
References: 1  Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-249@lists.php.net to get a copy of this message
Woah. Can we discuss this kind of stuff before you just go ahead and commit?! I don't think we should add such magic. Who says that false++ = true. Why isn't true++ false? Why is false-- == -1? This actually leads to pretty ugly coding. I think true and false should be treated as real enumerations. They intentionally couldn't be incremented nor decremented. If you need them to do so then you're most probably writing pretty bad code. Please revert all of the related patches both from Engine 1 and 2. Andi At 09:26 AM 7/14/2002 +0000, Derick Rethans wrote:
derick          Sun Jul 14 05:26:41 2002 EDT
Modified files:
    /Zend       zend_operators.c
Log: - Added 'type juggling' for boolean values. @- Added 'type juggling' for boolean values. The following conversions are @ done (Derick): @ $a = FALSE; $a++; /* $a is now bool(true); */ @ $a = TRUE; $a++; /* $a is now int(2); */ @ $a = FALSE; $a--; /* $a is now int(-1); */ @ $a = TRUE; $a--; /* $a is now bool(false); */ Index: Zend/zend_operators.c diff -u Zend/zend_operators.c:1.118 Zend/zend_operators.c:1.119 --- Zend/zend_operators.c:1.118 Sat Jun 29 03:38:49 2002
+++ Zend/zend_operators.c       Sun Jul 14 05:26:41 2002
@@ -1442,6 +1442,12 @@ ZEND_API int increment_function(zval *op1) {
        switch (op1->type) {
+               case IS_BOOL:
+                       if (op1->value.lval) {
+                               op1->type = IS_LONG;
+                       }
+                       op1->value.lval++;
+                       break;
                case IS_LONG:
                        if(op1->value.lval == LONG_MAX) {
                                /* switch to double */
@@ -1504,6 +1510,12 @@
        double dval;
        switch (op1->type) {
+               case IS_BOOL:
+                       if (!op1->value.lval) {
+                               op1->type = IS_LONG;
+                       }
+                       op1->value.lval--;
+                       break;
                case IS_LONG:
                        if(op1->value.lval == LONG_MIN) {
                                double d = (double)op1->value.lval;
-- Zend Engine CVS Mailing List (http://cvs.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.zend-engine.cvs (#249) next »