Thanks for the replies.
First, in response to Stefan...
> [EMAIL PROTECTED]:~$ php -r '$a = 2; $b = $a; debug_zval_dump($a);'
> long(2) refcount(3)
> [EMAIL PROTECTED]:~$
I missed that one. Thanks! With that I'd at least be
able to implement ref_count in php.
And then in response to Adam...
> > ============ (dis)allow_copies(mixed var) ============
>
> What about implementing this directly in php? You could use
> trigger_error in the constructor to stop the script from executing if
> the object is instantiated more than once.
I'll end up doing both. I'll do what you've mentioned to
get an error from the following code:
$s1 = new Singleton(); // Constructor sets non-member var to true
$s2 = new Singleton(); // The constructor will fail
I need disallow_copies() also though in order to get an error
from the following code:
$s1 = new Singleton(); // constructor calls disallow_copies($this)
$s2 = $s1; // With php4 I get a copy without any function call
or the following code:
function f($server) { // Bug! Should have been &$server
...
}
$s1 = new Singleton(); // constructor calls disallow_copies($this)
f($s1); // With php4 I get a copy without any function call
Finding those bugs when you have tens of thousands of lines of
php can be a real headache. That's why I'd very much like
a disallow_copies function.
Is anyone familiar with the extent of the uninitialized
struct issue I faced with the implemention I posted
yesterday?
Thanks again,
Todd
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php