The problem is that it makes it difficult to use recursive objects;
consider this code:

class A {
   var $b;
   function A() { $this->b =& new B($this); }
}
class B {
   var $a;
   function B(&$a) { $this->a =& $a; }
}

$one =& new A;
$two =& new A;
$three =& $one;

if ($one == $three) {
  echo "this works with the hashtable == test added";
}
if ($one == $two) {
  echo "this causes a fatal error without the E_WARNING patch";
}

I suppose that what I'm really after is an "is_same_object" test,
rather than a is_equal_object or is_identical_object.

Any chance that we could have something like this in the 4.3 release?
Essentially, the code just needs to compare the object properties hashtables
to decide if the objects are the same and return a boolean if that is the
case.

ZEND_FUNCTION(is_same_object)
{
   zval **obj1, **obj2;

   if (ZEND_NUM_ARGS() != 2 ||
     zend_get_parameters_ex(2, &obj1, &obj2) == FAILURE) {
        ZEND_WRONG_PARAM_COUNT();
   }

   if (Z_TYPE_PP(obj1) != IS_OBJECT || Z_TYPE_PP(obj2) != IS_OBJECT) {
       RETURN_FALSE;
   }

   RETURN_BOOL(Z_OBJCE_PP(obj1) == Z_OBJCE_PP(obj2)
     && Z_OBJPROP_PP(obj1) == Z_OBJPROP_PP(obj2));
}


--Wez.




On 09/29/02, "Zeev Suraski" <[EMAIL PROTECTED]> wrote:
> Do we really need a new #define there?  I think it's quite alright to bail 
> out in that situation as well...
> The check for the hashtables is fine though :)
> 
> Zeev
> 
> At 15:30 29/09/2002, Wez Furlong wrote:
> >that last patch was the wrong file, based on an earlier version :-/
> >here is the correct patch, which will raise a warning instead of a fatal
> >error, which at least gives the user the option of suppressing the problem
> >by using error_reporting().
> >
> >--wez.
> >
> >
> >
> 
>><file://c:\data%20files\eudora\attach\wez.zend.obj.compare.diff1.txt>469bd5.jpg<file://c:\data%20files\eudora\attach\wez.zend.obj.compare.diff1.txt>
> 
> >wez.zend.obj.compare.diff1.txt




-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to