Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47402 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16474 invoked from network); 18 Mar 2010 16:47:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Mar 2010 16:47:28 -0000 Authentication-Results: pb1.pair.com header.from=mathieu.suen@easyflirt.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=mathieu.suen@easyflirt.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain easyflirt.com designates 91.199.255.56 as permitted sender) X-PHP-List-Original-Sender: mathieu.suen@easyflirt.com X-Host-Fingerprint: 91.199.255.56 python-06.easyrencontre.com Linux 2.6 Received: from [91.199.255.56] ([91.199.255.56:59849] helo=mail.easyflirt.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E9/3A-20429-E1952AB4 for ; Thu, 18 Mar 2010 11:47:27 -0500 Received: from [192.168.0.51] (office.easyrencontre.com [78.155.152.6]) by mail.easyflirt.com (Postfix) with ESMTPSA id CD5056374E6; Thu, 18 Mar 2010 17:47:23 +0100 (CET) Message-ID: <4BA25919.8090805@easyflirt.com> Date: Thu, 18 Mar 2010 17:47:21 +0100 User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: Peter Lind , internals@lists.php.net References: <4BA0DF61.1010907@easyflirt.com> <4BA0E39C.7020600@gmail.com> <4BA0E9E8.8000404@easyflirt.com> <4BA1DB19.1080608@easyflirt.com> <660eb66f1003180224g5662ba1dtb123c3ee88a3a3e5@mail.gmail.com> In-Reply-To: <660eb66f1003180224g5662ba1dtb123c3ee88a3a3e5@mail.gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Assign array with __get From: mathieu.suen@easyflirt.com ("mathieu.suen") Peter Lind wrote: > > On the contrary, it's quite obvious what's going on. In both examples > __get() returns an array as PHP would normally do it (i.e. NOT by > reference) which means that if you try to modify that you'll end up > modifying nothing much. However, in your second example, the point at > which you call __get() indirectly comes before the assign to the zork > array - hence, the $this->zork['blah'] = 'blah'; no longer indirectly > calls __get as object::$zork now exists. > > In other words, this is down to you confusing passing a variable by > reference and passing it by value: PHP normally passes arrays by > value, so when __get() returns an array, you're working on a copy of > the array you returned. As someone noted earlier, you can easily > change the behaviour of __get to return variables by reference, should > you want to. However, I personally wouldn't want this to be default > behaviour as that would make debugging apps much more annoying - > things should be consistent, even if consistency at times confuse > people. > > Regards > Peter > > The sementic of $this->zork Should be the same as $this->__get('zork') So in that respect it is not consistent. But anywhere I don't care if it change or not. Look at Scheme, Lisp and Smalltalk language. This is what I call consistent language. -- Mathieu Suen