Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19341 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58812 invoked by uid 1010); 3 Oct 2005 13:45:25 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 58797 invoked from network); 3 Oct 2005 13:45:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Oct 2005 13:45:25 -0000 Received: from ([127.0.0.1:24198]) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with ECSTREAM id B1/E8-54476-5F531434 for ; Mon, 03 Oct 2005 09:45:25 -0400 X-Host-Fingerprint: 80.93.173.26 ostrich.skynet.co.uk FreeBSD 4.7-5.2 (or MacOS X 10.2-10.3) (2) Received: from ([80.93.173.26:62423] helo=ostrich.skynet.co.uk) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 58/58-54476-0C431434 for ; Mon, 03 Oct 2005 09:40:17 -0400 Received: from [80.93.173.34] (jupiter.sky.net.uk [80.93.173.34]) by ostrich.skynet.co.uk (8.13.4/8.13.4) with ESMTP id j93De7qm044140 for ; Mon, 3 Oct 2005 14:40:07 +0100 (BST) Date: Mon, 03 Oct 2005 14:39:39 +0100 To: PHP Developers Mailing List In-Reply-To: <122233927.20051003152138@marcus-boerger.de> References: <122233927.20051003152138@marcus-boerger.de> Message-ID: <20051003143244.8EC1.RICHARD.MANN@gg.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Becky! ver. 2.21.04 [en] Subject: Re: [PHP-DEV] $ref =& $this; From: richard.mann@gg.com (Richard Mann) Hmmm.... I agree about the reassigning of $this, but not the passing of $this by ref. Example: Class A { public $tableName = 'Forum'; public $childObject; public function __construct() { $this->childObject = new B($this); } } Class B { private $parent; public function __construct(&$parent) { $this->parent = &$parent; } public function get_stuff() { // Generate SQL useing the parents global table name settings etc.... } } On Mon, 3 Oct 2005 15:21:38 +0200 Marcus Boerger wrote: > Hello Derick, > > Monday, October 3, 2005, 3:09:22 PM, you wrote: > > > 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. > > Same here. > > > Best regards, > Marcus > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php ==================================================================== Richard Mann (Programmer) -= Skynet Internet Services a: 8 Premier Court Boarden Close Moulton Park Northampton NN3 6LF -= t: 0845 1 20 65 90 (General) t: 0845 1 24 44 00 (Sales) f: 0845 1 20 65 91 w: http://www.sky.net.uk/ -= D I S C L A I M E R Statements and opinions expressed in this e-mail may not represent those of the company. The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender immediately and delete the material from any computer. ====================================================================