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=3.8 required=5.0 tests=DNS_FROM_RFC_POST,HTML_10_20, HTML_MESSAGE,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id C049CBBC4 for ; Sat, 18 Apr 2009 16:48:24 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArkBAP6E6UnRVdqyimdsb2JhbACCUZMqPwEBAQoJDAcPBaUtgQmQEQEDAQODegY X-IronPort-AV: E=Sophos;i="4.40,210,1238968800"; d="scan'208";a="26445472" Received: from mail-bw0-f178.google.com ([209.85.218.178]) by mail3-smtp-sop.national.inria.fr with ESMTP; 18 Apr 2009 16:48:24 +0200 Received: by bwz26 with SMTP id 26so1302734bwz.27 for ; Sat, 18 Apr 2009 07:48:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=CrCfhMxnZQI3vlXW5676Z1rz/7HSLAHA9N7GGhqS7WY=; b=R3nk4sX4JvwmK1f1G8BZxwjWX17Je1f2/44pLLxqTE6N8gzaaw0nwHhXo4HGEjjlCT tRWmtGRDdpQLieu3kaFdBjaDL77DPKAVhN2y2yFszJh9c813H9+RsJl9F7uCt5sw5fZJ sytDRtZwIRrh373ndvPF+d0UeufOt+difBslQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=WS+3OlF46swdDHMH0Ui2R8ynlh6LYYbOsFPHUFvda9nNKWpbtDVZIUDqiL5vpbb3cT vsGA4vxI6KC58AoBWewf552+A5XlAAPoJIRqhwBCEIPgrVEzdsSdlAwqGhZXya/vuZkL aXIu5uxAUncEI4d/NowV5LubjZaJG8ECAyBaM= MIME-Version: 1.0 Received: by 10.204.31.218 with SMTP id z26mr3443862bkc.84.1240066103771; Sat, 18 Apr 2009 07:48:23 -0700 (PDT) Date: Sat, 18 Apr 2009 16:48:23 +0200 Message-ID: Subject: mixed functional / object style From: Guillaume Hennequin To: caml-list@yquem.inria.fr Content-Type: multipart/alternative; boundary=001485f7c48e9d01570467d563db X-Spam: no; 0.00; guillaume:01 val:01 mutable:01 val:01 mutable:01 guillaume:01 define:02 define:02 functional:02 objects:02 objects:02 naive:03 naive:03 let:03 let:03 --001485f7c48e9d01570467d563db Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Dear list, this is a somewhat naive question let's define class a = object val mutable v = ... method v = v method m = something that uses v end ;; now assume that I want to create a lot of those a objects, so many that I may encounter memory problems. I thought the following would be better, memory wise, but when I test it doesn't seem to be the case class a = object val mutable v = ... method v = v end ;; and instead of each object having its own method m, I define it separately let m x = something that calls x#v This question is somewhat equivalent to: what is the memory consumption of a simple method method m = let _ = self#v in () ?? Thanks a lot Guillaume. --001485f7c48e9d01570467d563db Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Dear list,

this is a somewhat naive question
let's define
=
class a =3D object
=A0val mutable v =3D ...
=A0method v =3D v
= =A0method m =3D something that uses v
end ;;

now assume that I wa= nt to create a lot of those a objects, so many that I may encounter memory = problems.

I thought the following would be better, memory wise, but when I test i= t doesn't seem to be the case

class a =3D object
=A0val mutab= le v =3D ...
=A0method v =3D v
end ;;

and instead of each obje= ct having its own method m, I define it separately
let m x =3D something that calls x#v

This question is somewhat equiv= alent to: what is the memory consumption of a simple method
method m =3D= let _ =3D self#v in () ??

Thanks a lot
Guillaume.

--001485f7c48e9d01570467d563db--