RE: [PHP-DEV] RE: PHP 4.0 Bug #6193 Updated: new object makes a shallow copy

From: Date: Fri, 18 Aug 2000 20:43:53 +0000
Subject: RE: [PHP-DEV] 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-29530@lists.php.net to get a copy of this message
HD>> Sorry - I don't. I designed and partially implemented very large projects. HD>> using reference counted C++ classes (C++ w/o pointers). This has nothing to do with what references are in PHP. Being skilled programmer doesn't mean that everything you think about PHP references automatically becomes true. Just like being skilled engineer won't help you if you want to make coffee with a toaster. HD>> - The double &'s are crazy and a very bad compiler design. HD>> This is not a bug - it's just a very bad design. HD>> Implementers give there problem back to the user, that's all. They are not "double". They mean different things. This could be improved by adding some more logic into the compiler, and maybe will be. But it has nothing to do with compiler design. HD>> - just never, never do implicit shallow copies HD>> (C++: copy constructor, Java: special function, ...) There's no such thing as "shallow copy" in PHP. What do you mean? HD>> - member(&x) { $x= &$this; } is broken. HD>> $x= &give_me_your_this(); // works HD>> member_function() { $x= &this; }; // fails No it isn't a bug. Please read my previous mails. HD>> - references-to-references does not work: HD>> $x= &$y->member(); HD>> $z= $x->member(); // works HD>> $z= $y->member()->member(); // fails This has nothing to do with references. It will be implemented in the future. HD>> - a automatically called destructor would leave the cleanup to HD>> the class designer. So the class user need to worry. There's no destructors in PHP, and no memory management for user-side of the language. This is a feature, not a bug. HD>> BUT, look at my example (the 100.000.000 loop). I as a class designer HD>> can destruct the circular reference easily. But, it's now the responsibility HD>> of the class designer not of the compiler. You say that you are creating 100M of objects *and* destroying them manually immediately? Show me such a program before I believe you. And believe me, you earn on reference counting many times more that you lose in one of such obscure cases. HD>> OK, my conclusion out of this discussion: we will give up PHP HD>> for everything more than 10 lines. You are a free adult, you make your choices. -- Stanislav Malyshev stas@zend.com +972-3-6139665 ext.106

« previous php.dev (#29530) next »