You are here: Re: [PHP] Re: Re: __get() not reentrant? « PHP « IT news, forums, messages
Re: [PHP] Re: Re: __get() not reentrant?

Posted by "Richard Lynch" on 05/23/05 15:32

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация