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=1.0 required=5.0 tests=AWL,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 discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 52BB7BC69 for ; Thu, 22 Feb 2007 20:55:48 +0100 (CET) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.171]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l1MJtlEO012929 for ; Thu, 22 Feb 2007 20:55:48 +0100 Received: by ug-out-1314.google.com with SMTP id k3so217566ugf for ; Thu, 22 Feb 2007 11:55:44 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=YVloSiDonuhe66jJNS3aga0T1Qn7Lh8QdJH1eVWvNRmvxEyWoalzo1dHdjIRt4S0uZr6XVr8OBCeag3I9kB2vAktorh2Ksr4rHT2Ti9nK87Nu3RAiDBw8W5bwkjk+bziUo5OomGFjDBK8YpKTk4fa+hYDvUCgxMBuUjReS1MTJ8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=fNT+go7SzTFNj05PPsujoAK/B+g3B4WNYjzHymxojpgzzyuUsWsEhznM32PqBR/GkM0pCTp/EtkkNCdx3oc5dneZMVRPB2J2d4kv5cvPq8oyF8YD4aMgvLFGy2FEU5NhOEzS/KrcVWZYV3GEsKLWmOABXBR3TblUyiRTQ+wnETA= Received: by 10.114.202.15 with SMTP id z15mr475356waf.1172174142891; Thu, 22 Feb 2007 11:55:42 -0800 (PST) Received: by 10.114.241.15 with HTTP; Thu, 22 Feb 2007 11:55:42 -0800 (PST) Message-ID: <875c7e070702221155q670f665dw829d72cebbe9acd8@mail.gmail.com> Date: Thu, 22 Feb 2007 14:55:42 -0500 From: "Chris King" To: "Joel Reymont" Subject: Re: [Caml-list] Instruction selection in the OCaml compiler: Modules or classes? Cc: caml-list@inria.fr In-Reply-To: <6CB0D237-F894-4AC3-BDBE-2BB484928D3C@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <6CB0D237-F894-4AC3-BDBE-2BB484928D3C@gmail.com> X-j-chkmail-Score: MSGID : 45DDF543.001 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 45DDF543.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 compiler:01 icfp:01 ocaml:01 compiler:01 subtyping:01 recursive:01 caml's:01 amaze:98 closures:01 closures:01 wrote:01 slides:01 slides:01 recursively:01 On 2/22/07, Joel Reymont wrote: > I'm reading through the icfp99 slides on classes vs modules in OCaml. > The part that I'm interested in starts on p27 where instruction > selection in the OCaml compiler is discussed. I've never seen these slides before; very interesting! Personally I prefer modules, but find classes useful for the typing tricks you can do with them: the ability to hide type variables via subtyping is one of the prime benefits. (The comparison in the slides between objects and closures I thought was particularly elucidating, since function closures are the other (clunkier) way of accomplishing the same thing.) Also of note, the slides talk about late binding being possible with classes but not with modules, but thanks to recursive modules late binding is in fact possible with (some) modules by simply having a "class" module accept a "Self" module as a parameter, whose members are used when late binding is desired. The final "object" module can then be created by recursively applying the (post-inheritance) "class" module to the "object" module. The power of Caml's module system continues to amaze me... :) - Chris