From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 7D59ABC69 for ; Sat, 8 Dec 2007 14:37:19 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAEMtWkfAXQInh2dsb2JhbACPYAEBAQgKKYEU X-IronPort-AV: E=Sophos;i="4.23,270,1194217200"; d="scan'208";a="5413011" Received: from concorde.inria.fr ([192.93.2.39]) by mail1-smtp-roc.national.inria.fr with ESMTP; 08 Dec 2007 14:37:19 +0100 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id lB8DbEZY008903 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Sat, 8 Dec 2007 14:37:19 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAMssWkeCNhAB/2dsb2JhbACRMg X-IronPort-AV: E=Sophos;i="4.23,270,1194217200"; d="scan'208";a="20114512" Received: from kurims.kurims.kyoto-u.ac.jp ([130.54.16.1]) by mail4-smtp-sop.national.inria.fr with ESMTP; 08 Dec 2007 14:37:12 +0100 Received: from localhost (orion [130.54.16.5]) by kurims.kurims.kyoto-u.ac.jp (8.13.8/8.13.8) with ESMTP id lB8Db6Ec018485; Sat, 8 Dec 2007 22:37:06 +0900 (JST) Date: Sat, 08 Dec 2007 22:36:48 +0900 (JST) Message-Id: <20071208.223648.27836833.garrigue@math.nagoya-u.ac.jp> To: dmitry.bely@gmail.com Cc: caml-list@inria.fr Subject: Re: [Caml-list] Class runtime representation From: Jacques Garrigue In-Reply-To: <90823c940712070559i5c435a10l76bbb3ec328690aa@mail.gmail.com> References: <90823c940712070559i5c435a10l76bbb3ec328690aa@mail.gmail.com> X-Mailer: Mew version 4.2 on Emacs 22.1 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 475A9E0A.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; runtime:01 ocaml:01 runtime:01 hash:01 computed:01 ocaml:01 hash:01 statically:01 functors:01 naming:01 dmitry:01 dmitry:01 caml-list:01 conflicts:01 conflicts:01 From: "Dmitry Bely" > Just curious: why Ocaml runtime should know class method names? Why > the method tag (a hash value computed from the name) is not enough? Good question. Names are only used during class construction, which is dynamic in ocaml. Names are used for methods (both public and private) and instance variables. Of all those, only public methods use a hashed values in other operations, and for this reason public methods in the same class are guaranteed to have no hash conflicts. But this is not enforced for private methods, which can always be called in a more direct way. And since some internal data structures mix private and public methods, it seems simpler to have names for all. Now, as we can also statically detect potential conflicts between private methods, it would be possible to use hashed tags for private methods too (and even instance variables). This might improve code size, as names would disappear from the runtime. This would not change performance however, as class construction only occurs once for most class declarations, and a fixed number of times in more complex examples combining inheritance and functors. And it would introduce a new restriction on the naming of private methods. Another reason names were kept is to eventually allow runtime introspection. This is not accessible currently, but the runtime knows the names of all methods in a class. Jacques Garrigue