From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA29614; Mon, 17 Mar 2003 20:01:49 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA27962 for ; Mon, 17 Mar 2003 20:01:47 +0100 (MET) Received: from mail.exomi.com (mail.exomi.com [217.169.64.72]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h2HJ1kf20206 for ; Mon, 17 Mar 2003 20:01:46 +0100 (MET) Received: from exomi.com (unknown [10.0.5.5]) by mail.exomi.com (Postfix) with ESMTP id B8CF35D03; Mon, 17 Mar 2003 21:01:44 +0200 (EET) Date: Mon, 17 Mar 2003 21:01:43 +0200 Subject: Re: Module recursion (Was Re: [Caml-list] Re: Haskell-like syntax) Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: "caml-list@pauillac.inria.fr" To: brogoff@speakeasy.net From: Ville-Pertti Keinonen In-Reply-To: Message-Id: Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) X-Spam: no; 0.00; recursion:01 caml-list:01 haskell-like:01 implemented:01 dependencies:01 scopes:01 outputs:01 permissive:01 mappings:01 non-trivial:01 hash:01 bindings:01 ocaml:01 variants:01 polymorphic:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > I think that two records that refer to each other belong in the same > module :-) That's a pretty strong generalization. My example doesn't involve only records specifically, but I think it is worth consideration. Note that this is based on my experiences while writing my first OCaml program, I have only been learning OCaml over the past couple of months in what little spare time I have, so it is entirely possible that there are better solutions available that I've missed. I've implemented a Scheme interpreter in OCaml (R5RS, including the full tower of number types, continuations, dynamic extents and hygienic macros, all implemented in OCaml with no Scheme library dependencies). OCaml was very well suited for this, but I thought it was annoying that I had to declare most of the types used in one file. IMO the only thing that should be visible throughout the program (and possible extensions) is the sum type of Scheme values/expressions but that wasn't reasonably possible. I would've wanted to make many of the specific types (pre-analyzed code in procedures, scopes of lexical bindings, dynamic extent records etc.) abstract, but couldn't. I could've made many of the types themselves abstract, since every operation relying on their specific content was isolated to a few functions, but the functions operating on those types require Scheme values as inputs and/or outputs, so that would've caused circular references between .mlis. (A notable exception was ports, which could be abstract and implemented without the need for knowledge of Scheme values) Additionally (and mostly unrelated to the above), I think that cases where there are a limited set of functions operating on an abstract type defined within a module could be more permissive. For an abstract type ('a, 'b) t of mappings from 'a to 'b, as long as no function operating on ('a, 'b) t returns 'a or accepts as an argument any function with an input of type 'a, it should be possible to create an instance of ('a, 'b) t where 'a is [> ] - it's possible to have such a variable, but (if I understand correctly - and I hope I do, because otherwise OCaml is broken) not as a member of an (unparametrized) record or object. I realize that this is a non-trivial wish, though, since it would require an analysis of what you can do with a type as well as a new implementation of polymorphic variants without the possibility of hash collisions. Still, I think that OCaml is a very interesting and powerful language, and in many respects more practical compared to other functional languages. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners