Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19536 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40562 invoked by uid 1010); 9 Oct 2005 13:27:45 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 40547 invoked from network); 9 Oct 2005 13:27:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Oct 2005 13:27:45 -0000 X-Host-Fingerprint: 84.60.24.221 dslb-084-060-024-221.pools.arcor-ip.net Received: from ([84.60.24.221:7114] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id F7/A2-54476-1DA19434 for ; Sun, 09 Oct 2005 09:27:45 -0400 Message-ID: To: internals@lists.php.net Date: Sun, 09 Oct 2005 15:27:35 +0200 User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: de-DE, de, en-us, en MIME-Version: 1.0 References: <00A2E2156BEE8446A81C8881AE117F192C15D6@companyweb> In-Reply-To: <00A2E2156BEE8446A81C8881AE117F192C15D6@companyweb> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Posted-By: 84.60.24.221 Subject: Re: AW: [PHP-DEV] return /* by reference */ new Foo() in PHP4 From: oliver.graetz@arcor.de (=?ISO-8859-1?Q?Oliver_Gr=E4tz?=) Matthias Pigulla schrieb: > Sorry, Olli, if that kind of ignores your statements, but I would like > not to distract from the issue. IIRC, what you suggested is called > "boxing" in C# and would lead too far here. I knew I was going further in my comment regarding this issue. It was never meant as an offense but as a backing of what you try to accomplish in a "Hey PHP coders, if you're not going as far as what I would like, hell, then please fix at least Matthias' problem." fashion. The "return new..." is just a subset of the problem, but not the only one that is in wide use. For example, this is very common: function &getstuff($in) { if ($in=='ok') return new MyObject(); else return false; // this is the common line } The "false" obviously is not a variable that can be reference and it's even not an object, the _technically_ more correct answer would be "return null;". But both ways of doing it are are not the "new ..." problem AND throw a notice AND PHP should be able to silently know what to do. Boxing is an approach that covers all of the similar problems and I think it could easily be realizedsince I suppose PHP is already doing something similar to fix the memory leak problems. > I wanted to focus only on the "return new ..." case and only on PHP4, as > "return new" is a very special case. This particular construct is really > unambiguous and the workaround on the PHP language level is really > nonsense. I don't understand the "only on PHP4": Why should PHP4 be more "advanced" than PHP5 regarding this issue? And more important: Why should the two versions differ in behaviour in such a basic point? > As to the notices, I will gladly accept them and take them as a helpful > pointers when "fixing" my "broken" code. The problem is that this > particular case causes a lot of "white noise" notices (at least in > heavily OO apps), as IMHO "return new" is not something that needs to be > fixed by me. Yep, good points. My humoristic approach to php.ini was suggesting to do something against this white noise. Some people like you and me believe they don't have to fix "return new" since it is perfectly legal code. So they want to kill this particuar notice but not all other ones. OLLi ____________ "I'm guessing you don't have a stuffed animal for me. Maybe a fifth of Jack Daniel's?" [4400 210]