Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88495 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22407 invoked from network); 25 Sep 2015 12:09:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Sep 2015 12:09:37 -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:32804] helo=mail.experimentalworks.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 72/33-31991-08935065 for ; Fri, 25 Sep 2015 08:09:37 -0400 Received: by mail.experimentalworks.net (Postfix, from userid 1003) id 9A6E54E548; Fri, 25 Sep 2015 14:09:37 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on km31408.keymachine.de X-Spam-Level: X-Spam-Status: No, score=-1.0 required=4.0 tests=ALL_TRUSTED autolearn=unavailable autolearn_force=no version=3.4.0 X-Spam-HAM-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP Received: from [192.168.2.34] (ppp-93-104-7-64.dynamic.mnet-online.de [93.104.7.64]) (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 E27994E548; Fri, 25 Sep 2015 14:09:35 +0200 (CEST) Message-ID: <1443182942.15520.13.camel@kuechenschabe> To: Dominic Grostate Cc: internals@lists.php.net Date: Fri, 25 Sep 2015 14:09:02 +0200 In-Reply-To: References: Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-4X0TfpM9eLBSOGMVuqsS" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Subject: Re: [PHP-DEV] Implementing Generics, and none scalar default properties. From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) --=-4X0TfpM9eLBSOGMVuqsS Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, Would be good to split complete different subjects to different threads anyways: On Wed, 2015-09-23 at 15:53 +0100, Dominic Grostate wrote: > the > ability to set default values of properties to instances of objects or > calls to static methods or functions (expressions in general). This causes questions on the order of execution and leads to waste of CPU time in case the constructor overrides the default value while not bringing much benefit over initialization in the constructor. It also is complicated regarding exceptions being thrown. Take the following code: p1, $this->p3); private $p3 =3D new Something(); private static $s1 =3D new StaticSomething(); public function __construct() {} } bar(); class B extends A { private $p4 =3D new Something(); public function __construct() { parent::__construct(); $this->p1 =3D new Whatever(); } } baz(); try { $b =3D new B(); } catch (Exception $e) { } ?> Some Questions: * Where, relative to foo(), bar() and baz() will StaticSomething's constructor be called? How do you capture exceptions from there? * When will $p2 be initialized, which properties can it access? (Only the ones initialized before? None?)=20 * In B's constructor we're overwriting $p1, so $p2 will be initialized with the wrong value. I'm sure there are more questions ... doing this i the constructor makes things clear and explicit with about the same amount of code to write. johannes --=-4X0TfpM9eLBSOGMVuqsS 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) iQEcBAABAgAGBQJWBTl1AAoJEH3sTmn8nIPXOnoH/0aeRmFNwttShYfM7BVrIKH1 nll4ttovICov6V33U/wMyU56ReYiePtptY/bTgYF7xL6m4GzAwI5En5yqpli1uG+ 03tKruAjXbD8by71AZFxhgLw23zfa6vi4qvDaysdk+njbXwyo4ljgQDdDSMUutK5 l1LCE82QdOa82LB6KlWSKEpb8KNSU8SJgMkKZpIakZng5LDZLqT26nNMTrUiZ9u3 lrlitwWlS12pGnmTga6kECcJYWluDvMWJTELQUuIUEjKyS7MAIz05rvISi6CSAhu nPfYA6drOiaIUx3ZbsD0b5ooIaPgSkkOqHdgwVx6Nq50UeSzqSN1KK5rysiGv5Y= =4mJI -----END PGP SIGNATURE----- --=-4X0TfpM9eLBSOGMVuqsS--