Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
How to correctly clone an object is a problem that people run into again and again and again, and the answer each time is that no general solution is possible.

Without semantic knowledge, it is not always possible to know in advance whether a shallow copy of the object is sufficient, whether a deep copy is required, or whether a correct copy requires something in between the two.

A shallow copy of an object treats instance data as static data that can be simply copied into a new instance. For some objects, including those based on arrays or hashes where all values are simple scalars, this works. But as soon as a value is a reference to another object, you have to make a choice between simply copying the reference (i.e., making a shallow copy), or recursively cloning the referred-to object (i.e., making a deep copy). In a moderately sophisticated system, you're liable to run into objects that require some combination of shallow and deep copying in order to be successfully cloned.


In reply to Re: Object::Clone a simple class providing a cloning method by dws
in thread Object::Clone a simple class providing a cloning method by jonasbn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (1)
As of 2021-12-07 04:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (33 votes). Check out past polls.

    Notices?