[m-dev.] Re: for review: deep copy cleanup.

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Jun 3 00:47:22 AEST 1998


On 02-Jun-1998, Lee Naish <lee at cs.mu.OZ.AU> wrote:
> Tyson Dowd <trd at cs.mu.OZ.AU> writes:
> 
> >Here's a cleanup of deep copy.  This should make it easier to add
> >other functions that need to do similar things. 
> 
> Prompted by a brief discussion on the tram last night about doing a
> binary dump of the HLDS in order to save information for declarative
> debugging:
> 
> It would be nice to document what happens if the original version of the
> data structure contains sharing.  With a (reasonably quick) look at the
> code it seems like 1) its not documented and 2) nothing clever is done,
> resulting in sharing being lost (ie, subterms get copied multiple times
> rather than shared) - in the worst case this can lead to a exponential
> increase in memory consumption.

Note that if you are using deep_copy for the purpose of creating a
unique data structure to which you can afterwards apply destructive
update, e.g. for the (in, uo) mode of copy/2 in library/builtin.m,
then you definitely *don't* want it to preserve or introduce sharing.

It would be useful to have versions of deep_copy which preserve
sharing, or which introduce sharing whenever possible, but these
need to be seperate versions -- we'll still need the current
version.

(Of course, we could have one function with an enum argument
rather than three separate functions.)

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.



More information about the developers mailing list