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.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 69158BC6B for ; Sat, 24 Feb 2007 03:51:36 +0100 (CET) Received: from ipmail01.adl2.internode.on.net (ipmail01.adl2.internode.on.net [203.16.214.140]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l1O2pYQT001099 for ; Sat, 24 Feb 2007 03:51:35 +0100 Received: from ppp41-119.lns2.syd6.internode.on.net (HELO rosella) ([59.167.41.119]) by ipmail01.adl2.internode.on.net with ESMTP; 24 Feb 2007 13:21:33 +1030 X-IronPort-AV: i="4.14,213,1170595800"; d="scan'208"; a="92721004:sNHT23017974" Subject: Re: [Caml-list] Instruction selection in the OCaml compiler: Modulesor classes? From: skaller To: Andreas Rossberg Cc: caml-list@inria.fr In-Reply-To: <007401c75780$c87c53d0$15b2a8c0@wiko> References: <6CB0D237-F894-4AC3-BDBE-2BB484928D3C@gmail.com> <007401c75780$c87c53d0$15b2a8c0@wiko> Content-Type: text/plain Date: Sat, 24 Feb 2007 13:51:28 +1100 Message-Id: <1172285488.23720.53.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 45DFA836.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 compiler:01 0100,:01 rossberg:01 subtyping:01 functor:01 functor:01 ocaml:01 hashtbl:01 int':01 reused:01 recursion:01 modular:01 integers:01 integers:01 On Fri, 2007-02-23 at 20:28 +0100, Andreas Rossberg wrote: > Tom wrote: > > > > I think you should take a look at another currently active thread - > > "Feature request : Tuples vs. records". One of the red lines there is the > > comparison of structural versus nominal typing - classes and objects > > belonging to the former, and modules and records to the latter. > > Not exactly: ML modules employ fully structural typing and subtyping. That > is their big strength, in contrast to comparable features in most other > languages (particularly typical notions of class). I wonder if more explanation could be given here? I admit continuing to be confused by the status of modules. It seems like a module functor allows both anonymous signatures (structural) and also anonymous argument modules (structural), yet you cannot have anonymous functor applications: you have to bind the application to a module name. If we really had structural typing that name would simply be an alias. Why can't we eliminate that name? *** C++ template applications can be anonymous, and that gives them a major edge over Ocaml modules. Similarly, when you're lucky enough to be able to use non-modular functor (a function with polymorphic type) it is much more convenient. For example Hashtbl provides both alternatives, whereas Set and Map do not (a fact many people complain about). *** more precisely, we probably don't want to eliminate the name most of the time, but we would like to be able to use a 'Set of int' in several modules without having to *export* the type in another module so it can be reused. This is particularly annoying when it is intractable: for example I have variant terms some of which contain sets of terms .. the recursion is easy to represent with lists but you can't do it with modular data structures. The way I do it is make sets of integers instead and keep a term table indexed by the integers. But this isn't really safe. There's probably a better way but the fact remains if I want the type safety I have to use lists or some other non-modular data structure: the modules actually get in the way of type safety instead of enhancing it. I guess the 'recursive modules' stuff will help fix this? -- John Skaller Felix, successor to C++: http://felix.sf.net