Re: __clone() implementation
| From: | Andi Gutmans | Date: | Mon, 02 Feb 2004 19:57:18 +0000 |
| Subject: | Re: __clone() implementation | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-7489@lists.php.net to get a copy of this message | ||
At 02:42 PM 2/2/2004 -0500, George Schlossnagle wrote:
On Feb 2, 2004, at 2:39 PM, Andi Gutmans wrote:Because it's a good way of retrieving the to-be-cloned object (no behind the scenes magic), and in my opinion, it's cleaner because everyone's clone functions will look the same and it'll make it easier to understand them. Why do you care so much if it's called $that or $foobar? What is important is that the problems with clone are fixed (almost). And you now have a consistent way of calling the parent clone method if you choose to. AndiAt 07:32 PM 2/2/2004 +0100, Ferdinand Beyer wrote:Clone methods must now be declared as follows: function __clone($that) { }On 2 Feb 2004 at 14:36, Zeev Suraski wrote:If you force the parameter to be name $that, what's the point of requiring it to be passed at all? Seems analogous to having all methods be required to pass $this as their first parameter.I just had a look at zend_compile.c - it seems as if the variable name $that was mandantory: [...] || strcmp(CG(active_op_array)->arg_info[0].name, "that")!=0)) {Because we want to keep it standard so that everyone uses the same thing (like previously). Anyway, $clone is semantically wrong because it implies that is the cloned object and not the to-be-cloned object.zend_error(E_COMPILE_ERROR, "The clone methodmust be declared as __clone($that)"); [...] Why shouldn't I be able to name it as I want, e.g. $clone? Don't understand the reason for that...