Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:8353 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29055 invoked by uid 1010); 3 Mar 2004 20:21:08 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 29026 invoked from network); 3 Mar 2004 20:21:07 -0000 Received: from unknown (HELO fed1mtao05.cox.net) (68.6.19.126) by pb1.pair.com with SMTP; 3 Mar 2004 20:21:07 -0000 Received: from notebook.local ([68.111.229.228]) by fed1mtao05.cox.net (InterMail vM.5.01.06.08 201-253-122-130-108-20031117) with ESMTP id <20040303202106.HTSB8957.fed1mtao05.cox.net@notebook.local>; Wed, 3 Mar 2004 15:21:06 -0500 Reply-To: truth@proposaltech.com To: Adam Bregenzer Cc: internals@lists.php.net In-Reply-To: <1078305931.6596.38.camel@arcon_server> References: <1078278552.17703.234.camel@notebook.local> <1078305931.6596.38.camel@arcon_server> Content-Type: text/plain Message-ID: <1078345266.2491.18.camel@notebook.local> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Wed, 03 Mar 2004 12:21:07 -0800 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Adding a few debug helpers to php4.x From: truth@proposaltech.com (Todd Ruth) Thanks for the replies. First, in response to Stefan... > et@edea:~$ php -r '$a = 2; $b = $a; debug_zval_dump($a);' > long(2) refcount(3) > et@edea:~$ 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