From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id E674FBD73 for ; Wed, 17 Aug 2005 00:40:03 +0200 (CEST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j7GMe2n3017270 for ; Wed, 17 Aug 2005 00:40:03 +0200 Received: from localhost (suiren [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.13.1/8.13.1) with ESMTP id j7GMduBh005410; Wed, 17 Aug 2005 07:39:57 +0900 (JST) Date: Wed, 17 Aug 2005 07:40:34 +0900 (JST) Message-Id: <20050817.074034.03110706.garrigue@math.nagoya-u.ac.jp> To: n8gray@gmail.com Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Representation of objects From: Jacques Garrigue In-Reply-To: References: X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 43026B42.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 asmrun:01 stdlib:01 invocations:01 superclass:01 bytecode:01 posts:01 hash:01 closures:01 compile:01 functions:01 essentially:01 jacques:01 jacques:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=DNS_FROM_RFC_ABUSE autolearn=disabled version=3.0.3 From: Nathaniel Gray > 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. Correct. > 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