From: Andrew Conway <arc@wildtype.Stanford.EDU>
To: 100060.2106@compuserve.com, garrigue@kurims.kyoto-u.ac.jp
Cc: caml-list@pauillac.inria.fr
Subject: Re: Oo.copy
Date: Tue, 28 May 1996 11:43:39 -0700 (PDT) [thread overview]
Message-ID: <199605281843.LAA10975@wildtype.Stanford.EDU> (raw)
>From: Jacques GARRIGUE <garrigue@kurims.kyoto-u.ac.jp>
>
>>>>>> ESPERET PHILIPPE <100060.2106@compuserve.com> writes:
>
> > I cannot understand how to access a fresh copy of an object with
> > O'Caml (Oo seems normally to copy only pointers). Thank you if someone
> > can explain me how to get such a copy (please see below for an example).
>
> > [ gives example of a class where a mutable element of the class
> > (an array) is not copied by OO.copy ]
>
>The problem is that your array is shared between the two copies.
>There are various specific ways to solve it.
I think that is a bad feature. I realise it may be unavoidable.
In particular, when I read the documentation for OO.copy, I assumed
that it was a function that descended the data structure, copying
all mutable structures. This seemed like a very useful thing to me
(and I wish it was available for any given type, not just classes).
I can immagine that this is impractical due to the overhead involved
in building specific "deep" copy functions for each data type defined
(that could possibly contain a mutable data structure), unless the
GC information contains enough of a specification to write a general
copy function similar to the general comparison functions. This would perhaps
only take one bit per block...saying whether the particular block
is mutable or not. On the other hand, I do realise that bits are expensive.
>One is to add an "unsharing" method in the virtual class, which is
>applied after copying.
Ugh!
> ...
>
>This is difficult to have a general way, since mutable data structures
>can get various forms.
Agreed.
Andrew.
next reply other threads:[~1996-05-29 10:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-05-28 18:43 Andrew Conway [this message]
1996-05-29 1:53 ` Oo.copy Jacques GARRIGUE
-- strict thread matches above, loose matches on Subject: below --
1996-05-25 20:25 Oo.copy ESPERET PHILIPPE
1996-05-28 11:48 ` Oo.copy Jacques GARRIGUE
1996-05-28 13:06 ` Oo.copy Didier Remy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199605281843.LAA10975@wildtype.Stanford.EDU \
--to=arc@wildtype.stanford.edu \
--cc=100060.2106@compuserve.com \
--cc=caml-list@pauillac.inria.fr \
--cc=garrigue@kurims.kyoto-u.ac.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox