Re: RE: PHP 4.0 Bug #6193 Updated: new object makes a shallow copy

From: Date: Fri, 18 Aug 2000 10:57:22 +0000
Subject: Re: RE: PHP 4.0 Bug #6193 Updated: new object makes a shallow copy
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-29384@lists.php.net to get a copy of this message
Today the constructor always returns (after the assignment) a copy! Other member functions I can tell with the two '&' to behave different. But &new and &constructor does not work!
I´ve filed a bug report regarding this.
!!! NO MEMORY LEAK EVEN AFTER 100 million loops !!! My actual test case was quite a bit more complex. A Cart did become many Items in each loop ($pItem was an array of item references). Please note, this structure in C++ would never leak because the destroy functions would be called automatically by "unset $cart". In PHP I have not to forget to call $cart->destroy()!!!
Well, one of the core-devs zeev?) mentioned that there´s no clean to implement destructors in PHP. I don´t know if it´s that hard to call a defined function on unset(), maybe we would document that people have to write their own destructors and need calling them working with circular references.
Please also understand, that here I need to place many '&'s or the structure doesn't work - in Java or in C++ the structure above works w/o any spezial. (not completely true, in C++ I SHOULD make sure that there is never a shallow copy done by overwritting the copy constructors).
That´s the intended way I think, function parameters are copied except you´re using & and = of course copies while =& references... regards -- o----------0-¬---------O-·---¬----o---®-----o o O ° . | http://www.kiffen.de | pRoteçt y0ur bRaín |0 O ° ¤ ° · 0°·³°²'²³-¹'³´³°^°³~³²³°'³²²¨³²^³¹³²°²³`³º³°Þ ° o © ° . · | psychedelic experience | gott@kiffen.de | O ° o ° o-¬--o--0-----©-·--O-----o-----0-¤----------o 0 ° · ° . ¤ ·

« previous php.dev (#29384) next »