Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19343 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69011 invoked by uid 1010); 3 Oct 2005 14:06:15 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 68995 invoked from network); 3 Oct 2005 14:06:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Oct 2005 14:06:15 -0000 X-Host-Fingerprint: 84.204.52.251 promo.hnet.spb.ru OpenBSD 3.0-3.4 Received: from ([84.204.52.251:44217] helo=promo.hnet.spb.ru) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id C9/0A-54476-4DA31434 for ; Mon, 03 Oct 2005 10:06:12 -0400 Received: from thinkpad (unknown [10.1.0.118]) by promo.hnet.spb.ru (Postfix) with ESMTP id EA6971BAC9B; Mon, 3 Oct 2005 18:05:50 +0400 (MSD) To: "'Derick Rethans'" , "'PHP Developers Mailing List'" Date: Mon, 3 Oct 2005 18:05:56 +0400 Message-ID: <002a01c5c823$97c04d20$e902a8c0@thinkpad> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 In-Reply-To: Importance: Normal Subject: RE: [PHP-DEV] $ref =& $this; From: dmitry@zend.com ("Dmitry Stogov") References: Hi, At first $ref =& $this; produced fatal error because of the bug (not by design). For example $ref->prop =& $this; worked and works without errors. So my patch shouldn't be reverted in any case. At second disallowing such assignments and passign $this by reference will breake a lot of PHP4 code (Mamaba CMS). In PHP4 passing $object by refernce and by value had completely different semantic. I don't see any reason to disallow 100% proper code (like the the following). class Child { function Child($parent) { $parent->children[] =& $this; } } Of course using "=& $this" user can breake $this value, but other languages (C++) allows this too. I don't think we should be paranoiacs. Thanks. Dmitry. > -----Original Message----- > From: Derick Rethans [mailto:derick@php.net] > Sent: Monday, October 03, 2005 5:09 PM > To: PHP Developers Mailing List > Subject: [PHP-DEV] $ref =& $this; > > > Hello, > > Dmitry committed a fix earlier to ignore the & in the > statement above. I > think this is not a good thing to do as it's simply > conceptually wrong. > The first thing is that ignoring syntax without issuing a warning is > dubious because people might think it does actually work, and > secondly > because I think that the code above is wrong anyway - somewhat in the > same way that "$this = new foo();" is wrong. > > There is never any need to assign $this by reference, nor to > pass it by > reference to a function as it's an object anyway, making the > references > pointless - I would even go as far as disallowing passing $this by > references to a function - where the reference has to be > ignored again, > otherwise it allows you to chantge $this to a different object with: > > class Foo { > function byRef(&$f) { > $f = new Bar(); > } > > function modifyThis() { > $this->byRef($this); > } > } > > I think we should prevent people from writing syntax like > this, as it is > not obvious what is going to happen. This means that we should revert > Dmitry's patch. > > regards, > Derick > > -- > Derick Rethans > http://derickrethans.nl | http://ez.no | http://xdebug.org > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >