Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Perl: the Markov chain saw
 
PerlMonks  

Re: Easy cloning leaving out selected attributes

by jeffa (Chancellor)
on Apr 17, 2012 at 00:03 UTC ( #965414=note: print w/ replies, xml ) Need Help??


in reply to Easy cloning leaving out selected attributes

But isn't that the point of cloning? If you want an object to have default attributes then just make a new one.


jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)


Comment on Re: Easy cloning leaving out selected attributes
Select or Download Code
Re^2: Easy cloning leaving out selected attributes
by mzedeler (Pilgrim) on Apr 17, 2012 at 11:31 UTC

    The point is that some (few) attributes should never be cloned, while others should. In this case, I have some objects that are stored through KioukuDB, and it never makes sense that they get the same id as the original object.

    I have a role that provides default ids, so it would be nice to have the clone method default to that.

    Another thing I need to differentiate is between some attributes that should be shallow clones and others that should be deep clones (using the clone() method on them, of course).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://965414]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2014-04-25 08:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (585 votes), past polls