Reply to Re: [PHP] Quick Poll: PHP 4 / 5

Your name:

Reply:


Posted by Robert Cummings on 09/16/05 20:59

On Fri, 2005-09-16 at 10:28, Rasmus Lerdorf wrote:
> Stephen Leaf wrote:
> >
> > $this->urlArr[0] = array_pop($arr = explode("&",$this->urlArr[0]));
> >
> > I still have to scratch my head as to why I *need* that "$arr = "
> > prior to 5.0.5 this was not needed.
> > $this->urlArr[0] = array_pop(explode("&",$this->urlArr[0]));
>
> This is a much misunderstood issue. And we are still contemplating the
> best way to handle this. Let's take a step back to a really simple example:
>
> function foo() {
> return 3;
> }
> function bar(&$arg) {
> $arg = "banana";
> }
> bar(foo());
>
> What do we do with code like this? If you follow it through it is
> essentially doing:
>
> 3 = "banana";
>
> which makes very little sense and is probably something the developer
> would want to know about.

I think this is part of the problem. While I understand how you got

3 = "banana"

I don't agree with your position that the above code is incorrect,
rather I think there is a philosophical difference between some
developers as to what should be expected. Most programmers (I would
argue :), including myself say, Foo returns 3, the return value is
stored in a temporary container, the temporary container is then fed
into bar() which just happens to want a reference, so fine, it gets a
reference to a temporary container, then it sets the value to "banana".
So finally we get back out to the bar(foo()) calling scope and we
receive the temporary container. In which case the way people are using
these functions and references are perfectly valid and passing temporary
return containers to reference expecting functions is not necessarily a
bug, but a philosophical question of understanding what the hell you're
doing :) As you are seeing now, we now have a horrible situation where
the developer now has to care about whether they are passing a value to
a function expecting a reference or not, and if that function expects a
reference they now have to manually create a temporary container
themselves :/ Anyways, I've already accepted whatever comes out of all
this, but personally I don't think the code you showed above is wrong at
all :)

Cheers,
Rob.
--
..------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'

[Back to original 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

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