Re: Re: shared memory extention

From: Date: Fri, 16 Apr 2010 00:35:41 +0000
Subject: Re: Re: shared memory extention
References: 1 2 3 4 5 6 7 8  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-7166@lists.php.net to get a copy of this message
Hi!
If that's the case then how are is ref values handled? Everything I read says that php does copy on write, so two values can point to the same block of data. Can someone please clear this up for me. Thanks
You seem to be confusing variables (the thing you call $foo in the language) with zvals (which are internal engine data structures, implementing values). Two variables can point to the same zval, simplest case: $a = 1; $b = $a; $b and $a share the same zval, which has refcount of 2. Now, if we do: $b++; then "copy on write" (which is called "separation" in the engine) happens - $b becomes different zval from $a, and both would have refcount of 1 now. If we did: $b =& $a; then $a and $b would be reference-bound (still sharing same zval), meaning that when we modify either of them, no separation happens, and the modification would be reflected in both $a and $b. Note that despite the form of the operator, the relationship between $a and $b is entirely symmetric, neither of them is different from the other one in any way. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com

« previous php.pecl.dev (#7166) next »