> >Another one for my wish list: deep copying support built in. A devil
> >inside me thinks this should be a new assignment
> >operator. Damian? Sounds like this is up your alley. I want to do a
> >sanity check before taking up RFC space.
>
> Regardless of how this looks, it has some pretty significant ramifications
> for the internals. What, for example, should happen if you deep-copy a DBI
> object attached to an Oracle database?
I would say that encountering an "external component" such as a file handle
during a clone() should either shalow copy the component or else throw an
exception. Perhaps that should be configurable with a second parameter that
optionaly specifies a subroutine to be invoked on such a node (and whose
return value is used as the copied element):
# external component is fatal...
my $copy = clone($original, sub{ die "external component" })
# vs:
# external component is shallow copied...
my $copy = clone($original, sub{ $_[0] })
# vs:
# external component is deep copied...
my $copy = clone($original, sub{
system("cp $_[0] $_[0].clone");
DBI->connect($_[0].clone");
}
)
Damian