Re: [PHP-DEV] Assign array with __get

2010-03-31 Thread mathieu.suen
Auke van Slooten wrote: Stanislav Malyshev wrote: Hi! IMHO __get is not consistent at the first place. on possible example: It is perfectly consistent. You just need to read what it actually does: http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members

Re: [PHP-DEV] Assign array with __get

2010-03-29 Thread mathieu.suen
Stanislav Malyshev wrote: Hi! IMHO __get is not consistent at the first place. on possible example: It is perfectly consistent. You just need to read what it actually does: http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members instead of imagining wh

Re: [PHP-DEV] Assign array with __get

2010-03-26 Thread Auke van Slooten
Stanislav Malyshev wrote: Hi! IMHO __get is not consistent at the first place. on possible example: It is perfectly consistent. You just need to read what it actually does: http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members instead of imagining wha

Re: [PHP-DEV] Assign array with __get

2010-03-26 Thread Stanislav Malyshev
Hi! IMHO __get is not consistent at the first place. on possible example: It is perfectly consistent. You just need to read what it actually does: http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members instead of imagining what it could do. -- Stanislav M

Re: [PHP-DEV] Assign array with __get

2010-03-26 Thread mathieu.suen
Stanislav Malyshev wrote: Hi! So what you're saying is that it is *consistent* with regard to the implementation of methods/functions, i.e. __get behaves as an ordinary method. Yes, it does. IMHO __get is not consistent at the first place. on possible example: class A { protected $foo;

Re: [PHP-DEV] Assign array with __get

2010-03-25 Thread Stanislav Malyshev
Hi! So what you're saying is that it is *consistent* with regard to the implementation of methods/functions, i.e. __get behaves as an ordinary method. Yes, it does. -- Stanislav Malyshev, Zend Software Architect s...@zend.com http://www.zend.com/ (408)253-8829 MSN: s...@zend.com -- PHP I

Re: [PHP-DEV] Assign array with __get

2010-03-25 Thread Ionut Gabriel Stan
I guess you're gonna hate this :) So what you're saying is that it is *consistent* with regard to the implementation of methods/functions, i.e. __get behaves as an ordinary method. On Fri, Mar 26, 2010 at 1:49 AM, Stanislav Malyshev wrote: > Hi! > >> So, what's the reasoning behind this design

Re: [PHP-DEV] Assign array with __get

2010-03-25 Thread Stanislav Malyshev
Hi! So, what's the reasoning behind this design decision? Why is it supposed to work like this and not the other way around? Because when you return something by-value you can not have effects of its modification reflect on the original value. That's how by-value works. When you have by-ref

Re: [PHP-DEV] Assign array with __get

2010-03-25 Thread Ionut G. Stan
Hi, On 3/22/2010 21:49, Stanislav Malyshev wrote: Hi! I guess what Mathieu is trying to say is that this: ...is inconsistent with this: This is because you're doing it wrong. If you intend to modify the property, return it by-ref. Saying the magic "consistency" word doesn't change that. No

Re: [PHP-DEV] Assign array with __get

2010-03-22 Thread Stanislav Malyshev
Hi! I guess what Mathieu is trying to say is that this: ...is inconsistent with this: This is because you're doing it wrong. If you intend to modify the property, return it by-ref. Saying the magic "consistency" word doesn't change that. Now, I'm not really sure this is that bad, as there

Re: [PHP-DEV] Assign array with __get

2010-03-22 Thread Etienne Kneuss
On Mon, Mar 22, 2010 at 5:12 PM, mathieu.suen wrote: > You are right I am using the wrong language but i can't help. > Is not me who make the decision. So for want of anything better, > why not try to improve the tool. Improve it how exactly? I can't see how one can improve this part while keepin

Re: [PHP-DEV] Assign array with __get

2010-03-22 Thread mathieu.suen
You are right I am using the wrong language but i can't help. Is not me who make the decision. So for want of anything better, why not try to improve the tool. Peter Lind wrote: Have you considered that perhaps you're trying to use the wrong language for what you're doing? PHP does what it does

Re: [PHP-DEV] Assign array with __get

2010-03-19 Thread Peter Lind
Have you considered that perhaps you're trying to use the wrong language for what you're doing? PHP does what it does now consistently (in this regard) - what you're suggesting breaks that consistency. To gain what, exactly? On 19 March 2010 17:07, mathieu.suen wrote: > Right I could work around

Re: [PHP-DEV] Assign array with __get

2010-03-19 Thread mathieu.suen
Right I could work around the issue with the return by reference without any problem. I am still thinking that if you try to write a meta-circular interpreter you gonna work very hard to make this subtleties worked. And according to "Shriram Krishnamurthi" in his textbook PLAI: " a truly power

Re: [PHP-DEV] Assign array with __get

2010-03-19 Thread Ionut G. Stan
I guess what Mathieu is trying to say is that this: class Foo { public $bar = array(); } $foo = new Foo; $foo->bar[3] = 1; var_dump($foo); ...is inconsistent with this: class Foo { public function __get($property) { if (!

Re: [PHP-DEV] Assign array with __get

2010-03-19 Thread 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

Re: [PHP-DEV] Assign array with __get

2010-03-18 Thread Etienne Kneuss
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 >> modify

Re: [PHP-DEV] Assign array with __get

2010-03-18 Thread 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 whic

Re: [PHP-DEV] Assign array with __get

2010-03-18 Thread Etienne Kneuss
Hello, On Thu, Mar 18, 2010 at 8:49 AM, mathieu.suen wrote: > Etienne Kneuss wrote: >> >> Hello, >> >> On Wed, Mar 17, 2010 at 3:40 PM, mathieu.suen >> wrote: >> >>> >>> Ionut G. Stan wrote: >>> Hi, This is interesting and it appears the following change makes the snippe

Re: [PHP-DEV] Assign array with __get

2010-03-18 Thread Peter Lind
> I think there is a lot  to say why is not working but just look at those > 2 execution: > > 1st > class A > { > >        public function __get($name) >        { >                $this->$name = array(); >                return $this->$name; >        } > >        public function te

Re: [PHP-DEV] Assign array with __get

2010-03-18 Thread mathieu.suen
Etienne Kneuss wrote: Hello, On Wed, Mar 17, 2010 at 3:40 PM, mathieu.suen wrote: Ionut G. Stan wrote: Hi, This is interesting and it appears the following change makes the snippet work as expected: public function &__get($name); I think is that the $this->anArray['bar']

Re: [PHP-DEV] Assign array with __get

2010-03-17 Thread Etienne Kneuss
Hello, On Wed, Mar 17, 2010 at 3:40 PM, mathieu.suen wrote: > Ionut G. Stan wrote: >> >> Hi, >> >> This is interesting and it appears the following change makes the snippet >> work as expected: >> >>    public function &__get($name); > > > I think is that the $this->anArray['bar'] = 4; > > Genera

Re: [PHP-DEV] Assign array with __get

2010-03-17 Thread mathieu.suen
Ionut G. Stan wrote: Hi, This is interesting and it appears the following change makes the snippet work as expected: public function &__get($name); I think is that the $this->anArray['bar'] = 4; Generate the following bytcode: 0 FETCH_OBJ_W $0

Re: [PHP-DEV] Assign array with __get

2010-03-17 Thread Ionut G. Stan
Hi, This is interesting and it appears the following change makes the snippet work as expected: public function &__get($name); On 3/17/10 3:55 PM, mathieu.suen wrote: Hi, I came across a strange behavior when using the magic method __get and some instance variable that should be an ar