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] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php