Re: [PHP-DEV] Re: Confusing pointers in PHP 4 and 5

2004-06-10 Thread Derick Rethans
Hey, put this in thedocs somewhere? regards, Derick On Wed, 9 Jun 2004, Sara Golemon wrote: > That's true. What I left out of my explanation (in order to keep it simple) > is that when you "copy" a variable, a new label is created to point to the > same zval, and the zval's refcount is incrme

[PHP-DEV] Re: Confusing pointers in PHP 4 and 5

2004-06-09 Thread Sara Golemon
> I think, and I could be completely wrong, that copying a variable actually > creates a reference. The data is only copied when the variable referenced is > modified. > That's true. What I left out of my explanation (in order to keep it simple) is that when you "copy" a variable, a new label is c

Re: [PHP-DEV] Re: Confusing pointers in PHP 4 and 5

2004-06-09 Thread Andi Gutmans
In general, if you don't mean for it to be a reference semantically, you are best off not using references at all. PHP will do the right thing. Andi At 10:32 AM 6/9/2004 +0200, Bert Slagter wrote: Derick Rethans wrote: On Wed, 9 Jun 2004, Stephan Schmidt wrote: Yes, that is correct. No, it is not

Re: [PHP-DEV] Re: Confusing pointers in PHP 4 and 5

2004-06-09 Thread Bert Slagter
Derick Rethans wrote: On Wed, 9 Jun 2004, Stephan Schmidt wrote: Yes, that is correct. No, it is not. 'copying' a variable copies the structure to contain the variable, but not the data, but does NOT make a reference as that's a different concept. You are right that the data associated with a vari

RE: [PHP-DEV] Re: Confusing pointers in PHP 4 and 5

2004-06-09 Thread Derick Rethans
On Wed, 9 Jun 2004, Stephan Schmidt wrote: > Hi, > > > I think, and I could be completely wrong, that copying a > > variable actually > > creates a reference. The data is only copied when the > > variable referenced is > > modified. > Yes, that is correct. No, it is not. 'copying' a variable copi

RE: [PHP-DEV] Re: Confusing pointers in PHP 4 and 5

2004-06-09 Thread Stephan Schmidt
Hi, > I think, and I could be completely wrong, that copying a > variable actually > creates a reference. The data is only copied when the > variable referenced is > modified. Yes, that is correct. Stephan -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://w

[PHP-DEV] Re: Confusing pointers in PHP 4 and 5

2004-06-09 Thread Aidan Lister
I think, and I could be completely wrong, that copying a variable actually creates a reference. The data is only copied when the variable referenced is modified. "Bert Slagter" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Sara Golemon wrote: > > Every "variable" in PHP is a pair

[PHP-DEV] Re: Confusing pointers in PHP 4 and 5

2004-06-09 Thread Bert Slagter
Sara Golemon wrote: Every "variable" in PHP is a pair. > > [cut] $foo = 1; /*$foo (label) >1 (value) (is_ref=0, refcount=1) */ $bar = &$foo; /* $foo (label) -->1 (value) */ /* $bar (label) ---/ is_ref=1, refcount=2 */ Hope that helps. -Sara Thanks fo

[PHP-DEV] Re: Confusing pointers in PHP 4 and 5

2004-06-08 Thread Sara Golemon
> As you can see the original tree now contains a pointer, how can that > be, I didn't change the original array!? > So what I'd like to know is: Is this intended behavior, and if so: why > does it work like this and would it make some operations impossible? > The truth of it is, this was true in