Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47424 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80807 invoked from network); 19 Mar 2010 07:51:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Mar 2010 07:51:32 -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:44963] helo=mail.easyflirt.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 28/12-62116-20D23AB4 for ; Fri, 19 Mar 2010 02:51:31 -0500 Received: from [192.168.0.51] (office.easyrencontre.com [78.155.152.6]) by mail.easyflirt.com (Postfix) with ESMTPSA id BE7B16374EC for ; Fri, 19 Mar 2010 08:51:27 +0100 (CET) Message-ID: <4BA32CFD.5050204@easyflirt.com> Date: Fri, 19 Mar 2010 08:51:25 +0100 User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: 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> <4BA25919.8090805@easyflirt.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Assign array with __get From: mathieu.suen@easyflirt.com ("mathieu.suen") Etienne Kneuss wrote: > On Thu, Mar 18, 2010 at 5:47 PM, mathieu.suen > wrote: > >> 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') >> >> > > $this->zork is only the same as $this->__get("zork") if zork is > undefined, this is perfectly normal and expected. > I would be very interested if someone already try to implement a meta circular interpreter. > >> 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 >> >> -- Mathieu Suen