English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-08-16 (22:40)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] Representation of objects
From: Nathaniel Gray <n8gray@gmail.com>

> I've been poking around a bit into the representation of objects in
> OCaml and I'm a bit confused.  Based on caml_get_public_method in
> asmrun/obj.c and various bits of stdlib/camlinternalOO.ml I see that
> the method table is an "array" where the even entries are closures and
> the odd entries "tags" -- hashed method names.  (The first two entries
> are special.)  The table is stored sorted in order of increasing tag
> value.  Please correct me if I've misunderstood something here.


> I've got two questions:
> 1.  Does this mean that essentially all method invocations need to
> search the method table?  The method table of a superclass is no
> longer a prefix of that of a subclass.  There's a GETMETHOD(i,obj)
> bytecode, but I'm struggling to figure out when you could use it.

>From other posts, it seems that you have found caml_get_public_method.

> 2.  What about hash collisions?  There's no collision resolution code
> in the method lookup functions.

The type system prevents them. That is, if there is a potential
collision between tag names, it will be detected at compile time.

Jacques Garrigue