Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10365 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 46363 invoked by uid 1010); 10 Jun 2004 07:12:20 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 46335 invoked from network); 10 Jun 2004 07:12:20 -0000 Received: from unknown (HELO jdi.jdimedia.nl) (212.204.192.51) by pb1.pair.com with SMTP; 10 Jun 2004 07:12:20 -0000 Received: from localhost (localhost [127.0.0.1]) by jdi.jdimedia.nl (8.12.10/8.12.10) with ESMTP id i5A7CJH2004526; Thu, 10 Jun 2004 09:12:19 +0200 Date: Thu, 10 Jun 2004 09:11:54 +0200 (CEST) X-X-Sender: derick@localhost To: Sara Golemon cc: internals@lists.php.net In-Reply-To: <20040609165619.27561.qmail@pb1.pair.com> Message-ID: References: <20040608091715.6553.qmail@pb1.pair.com> <20040608185216.38360.qmail@pb1.pair.com> <20040609072455.27050.qmail@pb1.pair.com> <20040609081333.7480.qmail@pb1.pair.com> <20040609165619.27561.qmail@pb1.pair.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [PHP-DEV] Re: Confusing pointers in PHP 4 and 5 From: derick@php.net (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 incrmented but the is_ref flag is > *not* set (I referred to this offhand as non-reference manner of multiple > labels referring to the same value). Then when one of the referring labels > says "I want to change my `copy` of the data." It notices that someone else > is also referring to this value (in a non-reference manner) and "separates" > the zval: This amounts to making a true copy of the zval (with a refcount > of 1, and an is_ref of 0) and decrements the refcount of the original zval > (since one fewer label is referring to it). This is the process known as > "copy on change". > > $foo = 1; > > /* $foo (label) ------> 1(value) (is_ref:0 refcount:1) */ > > $bar = $foo; > > /* $foo (label) -------> 1(value) */ > /* $bar (label) ---/ (is_ref:0 refcount:2) */ > > $foo = 2; > > /* $bar (label) -------> 1(value) (is_ref:0 refcount:1) */ > /* $foo (label) -------> 2(value) (is_ref:0 refcount:1) */ > > -Sara > > Ya just had to make it complicated didn't you. > >