Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84762 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10696 invoked from network); 14 Mar 2015 06:49:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Mar 2015 06:49:19 -0000 Authentication-Results: pb1.pair.com smtp.mail=cryptocompress@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=cryptocompress@googlemail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 74.125.82.53 as permitted sender) X-PHP-List-Original-Sender: cryptocompress@googlemail.com X-Host-Fingerprint: 74.125.82.53 mail-wg0-f53.google.com Received: from [74.125.82.53] ([74.125.82.53:35319] helo=mail-wg0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 05/E1-34457-EE9D3055 for ; Sat, 14 Mar 2015 01:49:19 -0500 Received: by wgdm6 with SMTP id m6so3565041wgd.2 for ; Fri, 13 Mar 2015 23:49:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=KzFurbzqc/1L//fYgDSBEdDBo5GpmFB4YTTCVF8FOZQ=; b=RaTa4dVeGAVcMiyZT1rXJ9Uo4N6IelzwRlaBZp4tvM8mW2n+GWxWN9Uqv0gnLW3983 lJfPmjonmm7OlpbCseCkXOm7K4gmypEpVeF7G/NYerxxK9xGPBBnmVwegSKa3W6/f23c dcuCvLb/G8Lp6tVJEVE95/5yoEhBfVDrodKPAti2k2QhZLXx6A0eY8VM0jLzs5kniXTP szutTQgvEOuBnYAET5hC+E72WPVRWWlJ/3aE1MJ11UBjxCxIDHFk3rI/wUfhf58R98OE qJNhMMm4GVA1r/QrlMRN+6lokYx28if8VA7BYueENjp3q1jJ5o0pLyySJqYBNtO4jy36 5dEA== X-Received: by 10.180.95.97 with SMTP id dj1mr103127305wib.43.1426315755573; Fri, 13 Mar 2015 23:49:15 -0700 (PDT) Received: from [192.168.1.115] (mnch-5d858cf9.pool.mediaWays.net. [93.133.140.249]) by mx.google.com with ESMTPSA id ub1sm5748111wjc.43.2015.03.13.23.49.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Mar 2015 23:49:14 -0700 (PDT) Message-ID: <5503D9E8.1090008@googlemail.com> Date: Sat, 14 Mar 2015 07:49:12 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: PHP Developers Mailing List References: <6D.2C.32765.10EC0055@pb1.pair.com> <5500D967.5040800@gmail.com> <13.69.64353.73451055@pb1.pair.com> <5501876C.3020107@gmail.com> <3D.85.42021.3E7A1055@pb1.pair.com> <5501B77D.5010800@gmail.com> <85.D1.24603.247C1055@pb1.pair.com> <5501D328.9040800@gmail.com> <98.26.24603.C9DE1055@pb1.pair.com> <5501F823.3060805@gmail.com> <55028793.5040606@googlemail.com> <04.FE.24603.D5CB2055@pb1.pair.com> In-Reply-To: <04.FE.24603.D5CB2055@pb1.pair.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] static constructor From: cryptocompress@googlemail.com (Crypto Compress) Am 13.03.2015 um 11:30 schrieb Johannes Ott: > Am 13.03.2015 um 07:45 schrieb Crypto Compress: >> Hello Johannes, >> >> in other mails you argue with Rowan about global state. I think it's >> better to focus on innovation of "class context" in global scope, as >> it's impossible to reason the disadvantages of global state away. >> (Discussions on variable scope are painful too.) >> >> And two questions: >> 1. By definition cctor is guaranteed to be executed only once. Right? > Yes as the __static should be as well. See discussion with Rowan and > Patrick for details. > > As I already told, I still have to clearify howto react if an exception > occurs inside the static class constructor. I prefer at the moment the > variant that a second try will raise a fatal error. But I will think > about this before I'll prepare the RFC. > >> 2. In your examples you employ some external resources in cctor (e.g. >> logger, db, ini-files). Do you intend to propose a cdtor to release this >> resources? > For my understanding the lifecycle of a class is from the loading of the > class definition to the end of the application or until some explicit > class unload (don't know whether php has such feature). PHP has no explicit class domain unload feature and you do not plan to implement this. Okay. > If loading a > instance to a static member you must be aware that this instance will > live till the end of lifetime of the class (that is the basic of > static). But at the end I hope PHP is unsetting all static members as > well, which should trigger the destructor of this instance as well. > > If PHP is not reacting like this (but I'm sure it is because without all > suggested singletons here would be a huge memory and connection leak as > well), I know what my second rfc would be :D > > Second point if you open a resource to read some data inside a method > and do not assure that it is closed again either explicit inside the > method or on a global pattern (for example my DBAdapter I use to read, > holds a single connection to database which is closed at the very end of > run), this would be poor code inside the static constructor as well as > it would be inside every other method. This "poor code inside the static constructor" seems to be a crucial point of your RFC. > > So I do not see the need of a explicit class deconstructor, because the > language should already react correctly on this issues as I can see so far The language cannot know the order of dependencies and how to destruct them. > > Regards, Thank you!