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 TAA08691; Tue, 20 Mar 2001 19:18:26 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA08718 for caml-list@pauillac.inria.fr; Tue, 20 Mar 2001 19:18:25 +0100 (MET) 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 SAA07103 for ; Tue, 20 Mar 2001 18:44:11 +0100 (MET) Received: from localhost.localdomain (ppp88.dyn147.pacific.net.au [210.23.147.88]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f2KHi7X12643 for ; Tue, 20 Mar 2001 18:44:08 +0100 (MET) Received: from ozemail.com.au (IDENT:root@localhost [127.0.0.1]) by localhost.localdomain (8.9.3/8.8.7) with ESMTP id EAA32081; Wed, 21 Mar 2001 04:43:54 +1100 Message-ID: <3AB796DA.ABD786B1@ozemail.com.au> Date: Wed, 21 Mar 2001 04:43:54 +1100 From: John Max Skaller X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.12-20 i686) X-Accept-Language: en MIME-Version: 1.0 To: Chris Hecker CC: caml-list@inria.fr Subject: Re: [Caml-list] recursive modules redux, & interface files References: <4.3.2.7.2.20010318142842.00d85300@shell16.ba.best.com> <4.3.2.7.2.20010319034052.00d72ef0@shell16.ba.best.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Chris Hecker wrote: > > > Because types in a given implementation may or may not be present > >in the interface. > > Right, that's fine, but I only want to have them once, whereever they are. So, if it's a private type, it's in the ml file, and if it's public it's in the mli file (assuming I want one, if I don't then everything's public). How does having them duplicated buy me anything but trouble? > > Chris In C++, a function is either extern or static. There are only two options. [And non-local classes are _always_ extern] This is not so in Ocaml: you may wish to provide access to a component such as a function with a type more constrained than the actual implementation. For example: (* twoint.mli *) val twoint: int -> int * int (* twoint.ml *) let twoint x = (x,x) Here, the implementation is actually polymorphic, it will work for more than ints, but clients of the module 'twoint' cannot use this function to make a pair of floats. Here is another example: (* abstr.mli *) type t val get: t -> int val make: int -> t (* abstr.ml *) type t = int * int let get x = fst x let make x = (x,x+1) Here, the type t is implemented as a pair of ints. But the implementation is hidden from the client of the module. Note that the type 't' itself is not hidden. -- John (Max) Skaller, mailto:skaller@maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850 checkout Vyper http://Vyper.sourceforge.net download Interscript http://Interscript.sourceforge.net ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr