== Quote from Zeev Suraski ([EMAIL PROTECTED])'s article
> Andi and I have revisited the __clone() implementation and must agree that
> it wasn't quite right (mainly due to it not working with inheritance).
> We have rewritten it now (major change!!!) because we didn't want PHP 5 to
> be released with a fundamentally flawed mechanism.
>

Zeev,

Sounds good.

However let me precise some troubles with the new implementation.

1/ Imagine a class with members, but it does not implement __clone because the bit for 
bit copy is OK. Now you derive this class and you need to implement __clone. Because 
the first class does not implement it, you can't call parent::__clone (I assume). So 
this is the responsibility of the derived class to clone the base class. This is not 
only not clean, but private members won't be visible.

2/ It still does not help what I already mentioned: when a class implements __clone(), 
all its derived classes have also to implement it to transfer their own members.

For sure, in these 2 cases there are work arounds:
 * case 1: modify the base class to implement __clone,
 * case 2: implement __clone in the derived classes.

Another idea for case 1 could be to be able to call parent::__clone even if the class 
does not implement it and have the bit for bit copy (but just for the base class).

Regards,
Stephane

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to