If I recall correctly, the reason that the function needs to indicate it returns a reference AND you need to declare it when assigning variables is because the function will return a reference when instructed; however, you then need to inform the binary assignment operator that it should assign a reference. Essentially assignment usually assigns a copy of whatever it receives, whether it be a value or a reference. This might seem like inefficiency, but since data containers aren't actually copied until the data is modified, there is only the overhead of copying the container itself and not its data. I agree though, it would have been nice if the language could have figured it out itself, which should have been possible.
Cheers, Rob. On Thu, 2003-10-09 at 18:13, Curt Zirzow wrote: > On Thu, 9 Oct 2003 22:50:10 +0200, Esctoday.Com | Wouter Van Vliet > <[EMAIL PROTECTED]> wrote: > > > Thanks Curt. > > > > This solution works indeed. BUT, there's one but. Isn't there a way to > > not > > have to tell PHP that I want the return of $this->AddFoo() as a > > reference? > > In the actual code I want to worry as little as possible about specific > > things like this. Isn't it a little strange that you have to both let php > > know it's returning a reference as well as let it know that it's > > expecting a > > reference as return value? > > > > well you do need to worry about it somewhere, and i would think that the > function > declaration: > function &AddFoo() > > Would take care of this, but I think there is some strange things going on > with the > class. IIRC, issuing a > > $foo = $bar->AddFoo(); > > Doesn't return a reference. > > > Hopefully someone here can mabey give some more insite as to why there has > to be both the declaration and the call references. > > function &AddFoo() > -and- > $foo = &$bar->AddFoo(); > > > Curt. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- .------------------------------------------------------------. | 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. | `------------------------------------------------------------' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php