Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-10-04 (07:59)
From: Jacques Garrigue <garrigue@k...>
Subject: Re: [Caml-list]
From: james woodyatt <>
> 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

        Jacques Garrigue
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: