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 ° · ° . ¤ ·