Re: Re: Strange notation to create object

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

 



On Fri, 2005-06-24 at 14:09, Jason Barnett wrote:
> Robert Cummings wrote:
> ...
> > 
> > Yeah, *grin*. And on that note, there are times when you will actually
> > want $foo = &new SomeClass(); versus $foo = new SomeClass(); since
> > assigning by reference will break any previous references -- something I
> > forgot to mention to Matthew Weier when he challenged the relevance of
> > the snippet I sent.
> > 
> > Cheers,
> > Rob.
> 
> Indeed... Matt, hope you see this one.  I was quite surprised by the 
> results as well!
> 
> Rob, since you're explaining this to us now then I assume that the dev 
> team is well aware of this issue and this is intended behavior... or is 
> this something that will be fixed/changed so that we don't have copies 
> of references floating around?  Because that seems very unintuitive to 
> me... references to references seems like a better "default" behavior 
> unless there's a good reason why we shouldn't change.

This is intentional behaviour, there are times when you want a copy of a
reference and there are times when you want a reference to a reference.
For instance consider the following:

$foo1 = $foo2 = $foo3 = new a();

$foo2 = new b();

If these were references to references instead of copies of references
then $foo1, $foo2, and $foo3 would all now refer to the newly created b
object.

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.          |
`------------------------------------------------------------'

-- 
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