|
Posted by Robert Cummings on 06/24/05 21:26
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. |
`------------------------------------------------------------'
Navigation:
[Reply to this message]
|