Etienne Kneuss wrote:
On Thu, Mar 18, 2010 at 5:47 PM, mathieu.suen
<mathieu.s...@easyflirt.com> 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



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to