Re: oop5 basic rewrite informal RFC

From: Date: Wed, 09 Sep 2009 04:27:29 +0000
Subject: Re: oop5 basic rewrite informal RFC
References: 1 2 3 4 5 6 7 8 9  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969380824@lists.php.net to get a copy of this message
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: > –‚žˆkè<1 > ñÐa4€ 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

« previous php.doc (#969380824) next »