From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id oBQDvOo6027325 for ; Sun, 26 Dec 2010 14:57:24 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8PAHrYFk3ZSMDdZGdsb2JhbACWGI4ZCBoLCgYSAyG9EYVKBI4h X-IronPort-AV: E=Sophos;i="4.60,230,1291590000"; d="scan'208";a="93203737" Received: from fmmailgate01.web.de ([217.72.192.221]) by mail1-smtp-roc.national.inria.fr with ESMTP; 26 Dec 2010 14:57:19 +0100 Received: from smtp08.web.de ( [172.20.5.216]) by fmmailgate01.web.de (Postfix) with ESMTP id CBF641844CACB for ; Sun, 26 Dec 2010 14:57:18 +0100 (CET) Received: from [78.43.204.177] (helo=frosties.localdomain) by smtp08.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #2) id 1PWr66-0003Z8-00 for caml-list@inria.fr; Sun, 26 Dec 2010 14:57:18 +0100 Received: from mrvn by frosties.localdomain with local (Exim 4.72) (envelope-from ) id 1PWr66-0007BO-6M for caml-list@inria.fr; Sun, 26 Dec 2010 14:57:18 +0100 From: Goswin von Brederlow To: caml-list@inria.fr Date: Sun, 26 Dec 2010 14:57:18 +0100 Message-ID: <87bp48ab7l.fsf@frosties.localnet> User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: goswin-v-b@web.de X-Sender: goswin-v-b@web.de X-Provags-ID: V01U2FsdGVkX1+uVkPc98PmJNG5/34gmdwoKWrZJBHr9o3SCrHH wdGQg/D+MR7WXraFVyaW42Klroho3qHQCQUzO+3evoJH8N3Nja pGclCITL8= Subject: [Caml-list] Classes and memory foodprint + speed Hi, I want my classes to have some "variables" and there seem to be multiple ways to do this. So I'm wondering what the actual difference is for the memory foodprint and speed. So lets look at a trivial example: # class foo (init_x : int) = object val x = init_x method get_x = x end class bar (init_x : int) (init_y : int) = object inherit foo init_x val y = init_y method get_y = y end let t = new bar 1 2;; class foo : int -> object val x : int method get_x : int end class bar : int -> int -> object val x : int val y : int method get_x : int method get_y : int end val t : bar = # class foo (x : int) = object method get_x = x end class bar (x : int) (y : int) = object inherit foo x method get_y = y end let t = new bar 1 2;; class foo : int -> object method get_x : int end class bar : int -> int -> object method get_x : int method get_y : int end val t : bar = So what are the differences between the two? How are they represented in memory and how does that affect speed? Does it make sense to have "val x" if it isn't mutable? MfG Goswin