From: Jerome Vouillon <Jerome.Vouillon@inria.fr>
To: Nicolas Ollinger <nollinge@cs.utu.fi>,
Jerome Vouillon <Jerome.Vouillon@inria.fr>
Cc: caml-list@inria.fr
Subject: Re: Efficency in OCaml
Date: Fri, 10 Sep 1999 15:14:39 +0200 [thread overview]
Message-ID: <19990910151439.21068@pauillac.inria.fr> (raw)
In-Reply-To: <Pine.GSO.3.96.990904165113.25828A-100000@lena.cs.utu.fi>; from Nicolas Ollinger on Sat, Sep 04, 1999 at 05:26:33PM +0300
On Sat, Sep 04, 1999 at 05:26:33PM +0300, Nicolas Ollinger wrote:
> I played a little with objects representation in OCaml 2.xx. As far as
> I understand, at least in bytecode, class instances are represented as
> boxed values tagged object_tag with n+2 fields : then first field is the
> method array array described by Jerome in last mail, the second field
> seems to be a unique id associate to the object, other fields are used
> for instance variables in the order of declaration, inherited variables
> first. As the method array array is unique for each class, it can be used
> to identify the class (notice that classes are represented as global
> variables).
This is correct.
> I'm intrigued by this second field, what is the use of this
> id ? Where is the necessity to identify uniquely every object ?
This allows to compare objects using "(<)" or "compare" (and therefore
makes it easy to create sets of objects).
> Concerning marshaling of objects, a simple solution is to use a function
> like:
>
> let crunch o =
> let r = Obj.dup (Obj.repr o) in
> let idclass = compute_id (Obj.field r 0) in
> Obj.set_field r 1 idclass;
> Obj.set_tag r Obj.marshaled_object_tag
> r;;
>
> with compute_id a function that deduce a unique class id of the object.
>
> Then unmarshaling is just doing the inverse operation. Of course, if
> you want to share objects between different programs then you must add
> some information about the module in which the class is declared, and
> so one.
This would work. The hard part is to generate this information...
-- Jérôme
next prev parent reply other threads:[~1999-09-10 14:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <7qj9lv$aa9$1@goldenapple.srv.cs.cmu.edu>
1999-09-01 18:40 ` chet
1999-09-01 23:09 ` Jerome Vouillon
1999-09-04 14:26 ` Nicolas Ollinger
1999-09-10 13:14 ` Jerome Vouillon [this message]
1999-09-10 15:19 ` Hendrik Tews
1999-09-10 19:03 ` chet
1999-09-15 12:39 ` Jerome Vouillon
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=19990910151439.21068@pauillac.inria.fr \
--to=jerome.vouillon@inria.fr \
--cc=caml-list@inria.fr \
--cc=nollinge@cs.utu.fi \
/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