in reply to deep_copy objects question
Code is a problem, since there may be persistent state associated with it - how do you duplicate it? Handles almost always have state that cannot be duplicated to an independent copy.
Even if you assume that your structure does not contain anything but pure Perl objects, those object can contain references to code and handles. Moreover, the class implementations for the objects may be keeping class-wide state, which means the only valid way of copying the object implementation (from the class point of view) is to use a class-specific copy constructor, if the class allows this by implementing one.
This, of course, does not disagree with the other posters' suggestions - you can always take the risk and just deep-copy and re-bless anything you find. Just watch out for the consequences.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re^2: deep_copy objects question
by merlyn (Sage) on Aug 13, 2004 at 20:54 UTC | |
|
Re^2: deep_copy objects question
by JAMBOID (Sexton) on Aug 13, 2004 at 20:16 UTC |