Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60212 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92508 invoked from network); 19 Apr 2012 08:27:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Apr 2012 08:27:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=arvids.godjuks@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=arvids.godjuks@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.210.170 as permitted sender) X-PHP-List-Original-Sender: arvids.godjuks@gmail.com X-Host-Fingerprint: 209.85.210.170 mail-iy0-f170.google.com Received: from [209.85.210.170] ([209.85.210.170:52409] helo=mail-iy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 40/CE-03623-46CCF8F4 for ; Thu, 19 Apr 2012 04:27:16 -0400 Received: by iaeh11 with SMTP id h11so13738802iae.29 for ; Thu, 19 Apr 2012 01:27:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=TCNce7FFaAEfNlR56eiSTvDnvsl+Lci+39XaJBMGe34=; b=0cZ+fSoVI3+2gfNeT4NTH17b/1/nSfPSFCjTgNBd8buMeGvNXUCj6fp1Jhz4X/ppqd 4Y6DzLBCXBdclOH+5SJ0Gt7Yu72oXFT22cky069PEIVBI7KfxHsE304IdGoDzUnJQf2w 1+W3Ze5BYKTtKYjVQQLP2C8bvIb6kiFKxhEuEi0TwLLw4KDM2DYeI1CeoM13assuiXeP 3GW6KFQZ3rwtxeDGXhIpzINMy+yKvYn3YGZeHW11ggTuZ9IQ/nN0qkD+6LqHMvYMVtO/ j3TAZitxKWLp/l8K1JtsPBfIEHjWdMCqjzBPfemsj1egJClfkM66RsSp6ETNLuFGmI05 Rp0A== Received: by 10.50.189.200 with SMTP id gk8mr833818igc.8.1334824034116; Thu, 19 Apr 2012 01:27:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.64.134.233 with HTTP; Thu, 19 Apr 2012 01:26:52 -0700 (PDT) In-Reply-To: <701fba0b5d6f2c07a7eea59d4b5c68ea.squirrel@www.l-i-e.com> References: <01ed01cd19aa$58810e80$09832b80$@alliantinternet.com> <701fba0b5d6f2c07a7eea59d4b5c68ea.squirrel@www.l-i-e.com> Date: Thu, 19 Apr 2012 11:26:52 +0300 Message-ID: To: Richard Lynch Cc: PHP Internals Content-Type: multipart/alternative; boundary=14dae93408596423c404be03f064 Subject: Re: [PHP-DEV] Ability to assign new object to a class property. From: arvids.godjuks@gmail.com (Arvids Godjuks) --14dae93408596423c404be03f064 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I have to agree with Richard as a user-land developer. It looks nice, but knowing how people can twist things I don't think I would like this feature get implemented. It just add stuff that is crazy to debug. Consider someone adds a property and initializes a user-land object. That object has other object properties with are created and the chain goes on for 2-3 more levels. Dealing with a __construct or a dedicated init method is far easier and at least predictable stuff. I imagine someone initiating objects at property declaration and then somewhere in the code assigning the data they want the object to work with instead of just passing it in to the constructor or calling a dedicated method to do that right after creating an object. 19 =D0=B0=D0=BF=D1=80=D0=B5=D0=BB=D1=8F 2012 =D0=B3. 0:31 =D0=BF=D0=BE=D0= =BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Richard Lynch =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB: > On Sun, April 15, 2012 5:47 pm, Simon Schick wrote: > > Just to add a random thought .... > > When do you expect this code to be executed? > > > > class Foo { > > static public $foo =3D new StdClass(); > > } > > I may be too late to this party, but... > > For what it's worth, if the non-scalar initialization in class > definition were to be implemented, I, the naive PHP developer, would > expect the implementation to execute the new StdClass() exactly once > (either at compile time or on the instantiation of the first instance) > and Foo::$foo or whatever it is would be static in the sense that the > same instance of a stdClass would be shared by all Foo instances. > > I'm with Stas on this one though. > > Yes, it would be nifty syntactic sugar, and I used to yearn for it. > > But complex initializations in the constructor is something I've grown > used to, and now appreciate as a Feature. > > Trying to find all the little bits and pieces of non-scalar > initializations up and down the chain of a complex class hierarchy is > already difficult enough. > > Tossing in a bunch more places it can happen is Not Good (tm). > > -- > brain cancer update: > http://richardlynch.blogspot.com/search/label/brain%20tumor > Donate: > > https://www.paypal.com/cgi-bin/webscr?cmd=3D_s-xclick&hosted_button_id=3D= FS9NLTNEEKWBE > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --14dae93408596423c404be03f064--