Re: object refrences (POSSIBLE MAJOR BUG)
| From: | Robert Cummings | Date: | Thu, 11 Apr 2002 18:27:15 +0000 |
| Subject: | Re: object refrences (POSSIBLE MAJOR BUG) | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-82616@lists.php.net to get a copy of this message | ||
brad lafountain wrote:
>
> > As far as references go... I believe when you copy an object it is a
> > shallow copy, in otherwords, the object is copied, but not its members.
> > This behaviour is preferrable as far as I'm concerned. If you want a
> > deep copy try doing the following:
> >
> > $foo = new foo();
> > $fee = unserialize( serialize( $foo ) );
> >
> > That should provide a nice quick, clean solution for what you want while
> > not incurring the overhead most programmers would rather skip on every
> > object copy.
>
> I shouldn't have to $fee = unserialize( serialize( $foo ) ) everytime i want
> to get a copy of an object when the engine says it copys. That is FAR from
> 'clean'. A possible soultion for this to get around the speed vs functionality.
> The engine could keep track of a copy and when and only when a member gets
> change that is when it should make the copy of the member objects. So you get
> the speed but it is transparent to the user.
And I shouldn't have to wait for all the housekeeping code to do it's thing
to keep track of whether I'm changing a member variable or not. So I get the
speed don't need to do $foo = &$fee every time I want a change the member
variables of the original object. The engine says it copies... it doesn't say
it DEEP copies. Please understand the difference.
Cheers,
Rob.
--
.-----------------.
| Robert Cummings |
:-----------------`----------------------------.
| Webdeployer - Chief PHP and Java Programmer |
:----------------------------------------------:
| Mail : mailto:robert.cummings@webmotion.com |
| Phone : (613) 731-4046 x.109 |
:----------------------------------------------:
| Website : http://www.webmotion.com |
| Fax : (613) 260-9545 |
`----------------------------------------------'