Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85781 Return-Path: <johannes@schlueters.de> Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57907 invoked from network); 13 Apr 2015 15:24:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Apr 2015 15:24:10 -0000 Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 217.114.215.10 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 217.114.215.10 mail.experimentalworks.net Received: from [217.114.215.10] ([217.114.215.10:60158] helo=mail.experimentalworks.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7E/F1-41712-89FDB255 for <internals@lists.php.net>; Mon, 13 Apr 2015 11:24:09 -0400 Received: by mail.experimentalworks.net (Postfix, from userid 1003) id E91ED4A1AA; Mon, 13 Apr 2015 17:24:46 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on km31408.keymachine.de X-Spam-Level: * X-Spam-Status: No, score=1.4 required=3.0 tests=ALL_TRUSTED, DNS_FROM_AHBL_RHSBL autolearn=no version=3.3.2 X-Spam-HAM-Report: * 2.4 DNS_FROM_AHBL_RHSBL RBL: Envelope sender listed in dnsbl.ahbl.org * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP Received: from [192.168.2.34] (ppp-93-104-6-125.dynamic.mnet-online.de [93.104.6.125]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: johannes@schlueters.de) by mail.experimentalworks.net (Postfix) with ESMTPSA id 07BE54A1A8; Mon, 13 Apr 2015 17:24:41 +0200 (CEST) Message-ID: <1428938604.3492.21.camel@kuechenschabe> To: Johannes Ott <mail@deroetzi.de> Cc: internals@lists.php.net Date: Mon, 13 Apr 2015 17:23:24 +0200 In-Reply-To: <CB.90.41712.5B6CB255@pb1.pair.com> References: <CB.90.41712.5B6CB255@pb1.pair.com> Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-HrRemK24SWb6XEv7txYV" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Subject: Re: [PHP-DEV] New RFC draft "static class constructor" From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) --=-HrRemK24SWb6XEv7txYV Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, On Mon, 2015-04-13 at 15:37 +0200, Johannes Ott wrote: > finally I managed to do my first RFC draft. >=20 > https://wiki.php.net/rfc/static_class_constructor >=20 > I hope I have done everything correct so far and I'm looking forward to > your feedback on it. In my opinion this makes the language way more complex as there are more places which "suddenly" execute code but solves a small problem compared to that. (Which actually is an issue many people would suggest to avoid completely instead of ennobling this with a language feature. Why am I saying it makes the language more complex? - Your proposal seems to miss mentioning when exactly the method is executed. what is the output of a.php: <?php echo 'A: '.__FILE__.':'.__LINE__."\n"; class A { static function __static() { echo __CLASS__.'::'.__METHOD__."\n"; } } echo 'B: '.__FILE__.':'.__LINE__."\n"; class B { static function __static() { echo __CLASS__.'::'.__METHOD__."\n"; } } echo 'C: '.__FILE__.':'.__LINE__."\n"; ?> b.php: <?php echo 'D: '.__FILE__.':'.__LINE__."\n"; C::$foo =3D 23; echo 'E: '.__FILE__.':'.__LINE__."\n"; include 'a.php'; echo 'F: '.__FILE__.':'.__LINE__."\n"; class C { static $foo =3D 0; static function __static() { echo __CLASS__.'::'.__METHOD__."\n"; } } echo 'G: '.__FILE__.':'.__LINE__."\n"; class D extends B { static function __static() { echo __CLASS__.'::'.__METHOD__."\n"; } } echo 'H: '.__FILE__.':'.__LINE__."\n"; ?> Mind that in b.php we make use of class C above the declaration, which we can do as C is a simple class and can be bound early during compilation. Class D however can only be bound during run-time, after including a.php, which happens after C was already used. johannes --=-HrRemK24SWb6XEv7txYV Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQEcBAABAgAGBQJVK99wAAoJEH3sTmn8nIPXdJYIALO+paZ7033Wu9sCwzEsjM3u Z+Uw3wmkHuzpuYwosCZZdD+R4i8gwMP8G6OmyCU46UsQ16F3nuMJy2/yeMF5kE47 v/u+uRbFuWAPGyKtt+XwcHjOTuQahRJ2vk5V5d7mr6WL8rW7Ilk9rUnW5FqIU7Th 7ZTydpsGs0kRW5d+IGHi/u4W8IRGOmBhcl197xf9UcjbginzyqnX5WG7kHqL8eRS X6INY2vSYhk9CcfoKs5kL2MLNH9svY6TDZf6cMpJK0DEhpk6uWckQqQa2dqik0m6 vm4Glp6en+cOMe8/pP+E1j+e08MK8s8LxUG7CgJU7idIxHm8h171KSlpVjNMbec= =GLZi -----END PGP SIGNATURE----- --=-HrRemK24SWb6XEv7txYV--