Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Oo.id
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@k...>
Subject: Re: [Caml-list] Oo.id
From: james woodyatt <jhw@wetware.com>
> Reading the source code in the caml distribution really didn't help me 
> understand what's going on, so I'm asking the list again:
> 
> 	Why does every class object contain field with unique integer?

Since objects contain a method table, which is composed of closures,
using standard comparison functions on them would be unsafe. In
practice this was even worse as this worked somehow, but only part of
the time :-(
Using the address would be ok for equality, but not for compare, as
the GC may move things around: the result of compare might change.

So we had to add a unique id to each object, which is used for
primitive equality and comparison functions. This also seemed
reasonable to make it available to the user, for use in indexed data
structures.

        Jacques Garrigue
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners