Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » PHP
  • » [PHP-DEV] object-overloading: why not allow recursive calls? (5.1) hey, in zend_object_handlers.c function zend_std_read_property we protect against calling the __get function of an object if we [RSS Feed]

#1 Nov. 9, 2005 22:15:53

Andi G.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] object-overloading: why not allow recursive calls? (5.1) hey, in zend_object_handlers.c function zend_std_read_property we protect against calling the __get function of an object if we


This is intentional and I think it makes it much more fool-proof fordevelopers. Adding recursion protection can be very expensive andcomplicated, and it doesn't seem to make sense here. The idea is thatonce you're in the __get() method, you know exactly how yourproperties are mapped and can do the right thing. It's only this onemethod where you have your mapping anyway, not an entirely different place.Andi

At 12:35 AM 11/4/2005, Thies C. Arntzen wrote:hey,

in zend_object_handlers.c function zend_std_read_property we protect
against calling the __get function of an object if we're already in a
__get() function. (look for zobj->in_get) in that function.

i don't think we should be doing this.

simplyfied example:
<?php
class test {
function __get($offset) {
echo "__get($offset)\n";
switch ($offset) {
case 'name': return "name";
case 'length': return strlen($this->name);
}
}
}

$a = new test;
var_dump($a->length);
?>

outputs:
__get(length)
int(0)

but should say:
__get(length)
__get(name)
int(4)

i think recursive gets are highly useful and should be allowed. if we
really want to protect against recursion (here) we have two real
options: -a- protect against __get(ing) the same property more than
once in the same call-chain (mucho work), or -b- (preferred) have
some global infinite recursion protection in the engine (needs to be
done somewhen anyhow, but not now).

so, in one sentence: as we don't protect against recustion elsewhere,
can we please remove this unneded roadblock?

opinions?
-thies

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

Offline

#2 Nov. 9, 2005 23:07:34

Andi G.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] object-overloading: why not allow recursive calls? (5.1) hey, in zend_object_handlers.c function zend_std_read_property we protect against calling the __get function of an object if we


Thies,I think I might be wrong in my analysis. Seems like the problem isworse than what I thought as it seems to cross boundaries between classes.We'll look into it more.

Andi

At 02:15 PM 11/9/2005, Andi Gutmans wrote:This is intentional and I think it makes it much more fool-proof fordevelopers. Adding recursion protection can be very expensive andcomplicated, and it doesn't seem to make sense here. The idea isthat once you're in the __get() method, you know exactly how yourproperties are mapped and can do the right thing. It's only this onemethod where you have your mapping anyway, not an entirely different place.Andi

At 12:35 AM 11/4/2005, Thies C. Arntzen wrote:hey,

in zend_object_handlers.c function zend_std_read_property we protect
against calling the __get function of an object if we're already in a
__get() function. (look for zobj->in_get) in that function.

i don't think we should be doing this.

simplyfied example:
<?php
class test {
function __get($offset) {
echo "__get($offset)\n";
switch ($offset) {
case 'name': return "name";
case 'length': return strlen($this->name);
}
}
}

$a = new test;
var_dump($a->length);
?>

outputs:
__get(length)
int(0)

but should say:
__get(length)
__get(name)
int(4)

i think recursive gets are highly useful and should be allowed. if we
really want to protect against recursion (here) we have two real
options: -a- protect against __get(ing) the same property more than
once in the same call-chain (mucho work), or -b- (preferred) have
some global infinite recursion protection in the engine (needs to be
done somewhen anyhow, but not now).

so, in one sentence: as we don't protect against recustion elsewhere,
can we please remove this unneded roadblock?

opinions?
-thies

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

Offline

  • Root
  • » PHP
  • » [PHP-DEV] object-overloading: why not allow recursive calls? (5.1) hey, in zend_object_handlers.c function zend_std_read_property we protect against calling the __get function of an object if we [RSS Feed]

Board footer

Moderator control

Enjoy the 20th of November
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support