__clone arguments

php.internals

Eduardo R. Maciel

22 years ago
Sorry if it has been discussed before, but how is the question about __clone accept arguments ??? It would permit a better control when clonning objects, like dinamically setting properties. Sure its is possible using wrappers, but would be better if the function supports that. class clonable{ public $age; public $b; // function __clone($a){ // if ($a) $this->age = $a; // else $this->age = $that->age; // } } $molly = new clonable; $molly->age = 1; $dolly = $molly->__clone(0); echo $dolly->age; if ($dolly == $molly) echo "equal: TRUE"; else { var_dump($dolly); var_dump($molly); } if ($dolly === $molly) echo "identical: TRUE"; else { var_dump($dolly); var_dump($molly); } Eduardo R. Maciel __________________________________ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/

Andi Gutmans

22 years ago
It doesn't accept arguments. An object should know how to clone itself without additional information. If you want a method which does something other than cloning then define your own method. Andi At 10:14 AM 12/3/2003 -0800, Eduardo R. Maciel wrote:

Eduardo R. Maciel

22 years ago
I know the valids decision votes will be from the core developers (wich I am not). But I?d like to expose my suggestion: - PHP object oriented parts, like classnames, methods, atributes, etc could use studlyCaps as almost whole world use to with OO code. - Php procedural parts, like functions, vars, constants, etc could use underscore as almost the whole world use to with not OO code. Since PHP is a mixed language (procedural and Object Oriented) It would even help to diferentiate each paradigm. The way it would be easy to know when a external module supports OO features for example. And as Andi said, interfacing with external modules and interfacing with other technologies are growing up, and would help if it works like those other technologies. In the other hand, using underscores where code is not OO, would make clear to see that you are using the procedural way. Just imagine how complicated will it be if PHP programmers has to use several OO modules, and some of them use underscores, PEAR using studlycaps, another framework using undercores too, and other using studly, all Object Oriented. What a mess.... Defining all OO parts of PHP (and recomending it to external modules) as studlyCaps would follow a tendency which ALREADY EXISTS and not force all existant PHP OO code to be rewritten. And would keep things in order. Easy to manage. In the other hand, defining the use of underscores will break what already exists (about OO Code) and probably won?t be accepted as a consensus. Means that what I sad above (the messy code) can happen. IMO it would the best to do in this situation. __________________________________ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/

Eduardo R. Maciel

22 years ago
Why does not everybody consider the existent facts, and not what one likes and other does not like? It would be more logical. The facts: - There are already extensions that use studlyCaps(DOM, mysqli, and others), and probably WONT change. - In the future, probably several other external OO extensions will use studlyCaps. - Pear and other frameworks are using studlyCaps. - Almost all external technology wich PHP will interact now or in the near future uses studlyCaps. Why doesn?t make that a STANDARD for OO code so????? The only thing you will get if decide to use underscores, is that there will be a CS with several exceptions. Like somethings that use studlycaps and others that use underscores. And never will have a consistent Coding Standards. By the other side, adopt studlycaps for OO code will avoid all these problems and create a clear CS that CAN BE FOLLOWED (we know that adopting underscores will generate several exceptions). I think these are the facts to think about. I personaly, prefer underscores, but I think in this case studlyCaps should be used for OO code. And just because with it, is possible to create a consistent CS with no exceptions. Thanks, Eduardo R. Maciel __________________________________ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/