Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:7586 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96923 invoked by uid 1010); 4 Feb 2004 21:47:34 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 96899 invoked from network); 4 Feb 2004 21:47:33 -0000 Received: from unknown (HELO spawn.leetspeak.org) (217.28.101.185) by pb1.pair.com with SMTP; 4 Feb 2004 21:47:33 -0000 Received: from leetspeak.org (pD9E55B40.dip.t-dialin.net [217.229.91.64]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by spawn.leetspeak.org (Postfix) with ESMTP id 9EBB21C57 for ; Wed, 4 Feb 2004 22:47:36 +0100 (CET) Message-ID: <40216872.7020309@leetspeak.org> Date: Wed, 04 Feb 2004 22:47:30 +0100 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031210 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: internals@lists.php.net References: <5.1.0.14.2.20040204115844.04341008@localhost> In-Reply-To: <5.1.0.14.2.20040204115844.04341008@localhost> X-Enigmail-Version: 0.82.4.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] New destructors implementation From: cm@leetspeak.org (Michael Walter) Hi Andi, Andi Gutmans wrote: > [...] > > This has several implications: > > [...] > > 2. A *VERY* important implication is that you cannot, and must not rely in any way on the order of destruction during shutdown. It runs in no particular order. That means that by the time the destructor for your object $foo is called, a reference to some other object $bar may already be post-destruction. Note that it will still be 'intact' and accessible in the sense that if you access it - there won't be crashes. However, if this object does indeed have a destructor, it can be considered semantically wrong to touch this object at this point. Doesn't that render more sophisticated cases of objects with constructors sort of unusable? I mean, any scheme like class Wrapper: ctor: $this->m_resource=alloc_resource(); dtor: $this->m_resource=free_resource(); doWork(): do_this_and_that($this->m_resource); class Client: ctor: $this->m_wrapper=new Wrapper(); dtor: $this->m_wrapper->doWork(); is inherently unsafe, unless I totally got your message wrong (apologies for potential confusion). If you consider a common case such as the wrapper class wrapping a db connection or a file handle, and the client's destructor logging some "shutdown" message using that wrapper, I fail to realize how this would work with the given destructor scheme. I'm not too familiar with the old destruction scheme, but wouldn't a destruction scheme in which not all object destructors are called still be superior to one which is completely non-deterministic in terms of shutdown order? Or probably better, how about at least trying to shutdown in reverse creation order (and for all cases for which that won't work, use the new non-deterministic scheme)? > [...] Cheers, Michael PS: Apologies for obvious stupid remarks in this post, I'm sure I'm missing 1+ obvious issues