Re: Re: Re: __get() not reentrant?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, May 22, 2005 3:24 pm, Christopher J. Bottaro said:
> And what would make it any different from a normal recursive function?

The fact that *ANY* attempt to access a mis-typed property would kick in a
__get() call, and that's too frickin' easy to happen in code that's too
easy to fly by QA in large-scale applications springs to mind...

Not saying you're "wrong" or they're "right" just that it's not quite as
simple as a normal recursive function or loop iteration.

> Every recursive function runs the risk of going into infinite loop if the
> programmer doesn't understand the basic concept (or makes a silly
> mistake).

Just saying it's an easier silly mistake to mis-type: $whatever->fooo
instead of $whatever->foo and have that escape QA somehow.

> Loops run the risk of going on indefinitely as well.  Maybe PHP should
> disable all forms of loops/recursion to protect the programmers from
> themselves.

That does seem a bit excessive...

Maybe __get() should allow recursion and let the developer worry about
infinite recursion.

But, today, it doesn't, so deal with it and move on.

> What is wrong with that?  Why should PHP disallow that recursive __get()
> call?  It is perfectly valid recursive code.  It terminates for all cases.

What happens if you do:

class example {
  function __get($x){
    return $this->recursive_get($x);
  }

  function recursive_get($x){
    /* paste your current __get function body here */
  }
}

I suspect it will work just fine at the expense of one (1) extra function
call, which is not significant in recursion.

A recursive __get() has some serious implications to performance and
design decisions that painted you into this corner.

Obviously, it's entirely possible that your Design is the most elegant
beautiful disciplined bit of code since John von Nueman...  But it's more
likely, without knowing anything about you, that you've come up with this
as a result of some bad Design decisions.

Review your Design. :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux