RE: [PHP4BETA] OO Destructors
| From: | Andi Gutmans | Date: | Tue, 10 Aug 1999 20:00:56 +0000 |
| Subject: | RE: [PHP4BETA] OO Destructors | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-3309@lists.php.net to get a copy of this message | ||
Like Zeev mentioned the only way to make OO destructors really work is to take the Java approach where you have handlers to an object and the object holds the reference count.
For example, the following two lines would result in $a being a handle to a new object of type foo, and then $b would be a reference to the same object foo. Currently in PHP 3.0 and PHP 4.0 it makes $b be an actual copy of $a.
$a = new foo;
$b = $a;
This would also mean that when you pass an object by value to a function, it's not copied as the handler is passed which will point to the original object being passed. You'd have to copy it explicitly.
Personally I prefer the handler solution which would allow us to make destructors but I have a feeling that tons of people would be bitten by such a big incompatibility with PHP 3.0 which would make it not worth it. People won't move to PHP 4.0. I might be miscalculating how many ppl this would really bite but it's kind of scary.
Andi
---
Andi Gutmans <andi@zend.com>
http://www.zend.com/