Brandon Savage wrote: > On Sep 8, 2009, at 6:12 PM, Daniel Convissor wrote: > >> Hi Brandon: >> >> Nice stuff. Two qualms with the following: >> >> PHP 5's object model also significantly changes the way objects >> are passed, passing a pointer to the object rather than copying >> the object. >> >> First, "passed" is the followed immediately by "passing." Pick a >> different word for one or the other. >> >> Second, the documentation in general talks about it being "by reference" >> rather than as "a pointer." >> >> Thanks, >> >> --Dan > > Hi Dan, > > I have no trouble changing the wording on your first point, as it does > make the wording seem a bit odd. > > However, each spot where the documentation states that objects are > passed by reference is wrong. See this blog post by Sara Golemon: > http://blog.libssh2.org/index.php?/archives/51-Youre-being-lied-to..html > > Essentially, objects are like references, pointing to a particular spot > in memory where the object can be found. While it's easier to describe > objects as being passed by reference in PHP 5, this is in fact not the > case. > > I'm not sure how to change the documentation to reflect this. How > specific should we get in the documentation?
Hi, Don't use pointer, that's also inaccurate, and will be confusing to someone from a C background. Instead, use language somewhat similar to: PHP 5's object model was designed to make it simpler and faster to pass objects as parameters to functions and methods. Rather than copying the contents of the object, PHP 5 represents objects with a "handle" that is used to look up the actual object contents. The technical details are not important in most situations. The most important thing to understand is that the common PHP 4 practice of using references to instantiate and pass objects should not be used in PHP 5, for both the subtle bugs the practice can introduce and for performance reasons. Greg