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 HAA21459; Thu, 20 Nov 2003 07:06:20 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id HAA21771 for ; Thu, 20 Nov 2003 07:06:18 +0100 (MET) Received: from mail1.tpgi.com.au (mail.tpgi.com.au [203.12.160.57]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id hAK66G119595 for ; Thu, 20 Nov 2003 07:06:17 +0100 (MET) Received: from 203-213-85-204-syd-ts17-2600.tpgi.com.au (203-213-85-204-syd-ts17-2600.tpgi.com.au [203.213.85.204]) by mail1.tpgi.com.au (8.11.6/8.11.6) with ESMTP id hAK65v026703; Thu, 20 Nov 2003 17:05:57 +1100 Subject: Re: [Caml-list] GC and file descriptors From: skaller Reply-To: skaller@ozemail.com.au To: Brian Hurt Cc: Martin Berger , Caml Mailing List In-Reply-To: References: Content-Type: text/plain Message-Id: <1069303941.24578.35.camel@pelican> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 20 Nov 2003 16:05:30 +1100 Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 ozemail:01 stealing:01 mli:01 mli:01 implying:01 avoiding:01 decoupling:01 implemented:01 compiler:01 compiler:01 formed:98 descriptors:01 int:01 int:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, 2003-11-20 at 04:43, Brian Hurt wrote: > 2) introduce a new keyword 'private'. Everything except those types and > values marked private is exported. > > Note that we're breaking working code here. I do not see how, except that the keyword private is already used :-) I suggested previously a third keyword would be useful, 'abstract' which is used like: abstract type x = y; which generates the interface type x; I think this is called "limited private" in Ada? This does not break anything (apart from stealing some identifiers as keywords). The assumption is that there is only an .ml file, no .mli file: if you don't use private or abstract keyword, the result is the same as it is now. If you do, you're using an extension which is not well formed syntactically at present, and so no existing code can be broken. The only real difficulty here is: "what if there is an .mli file that disagrees with the .ml file?" This can already happen: a constraint on a function type, or a function that isn't in the interface at all. But what if a function is marked private in the ml file but exists in the .mli file, implying public? I guess the best answer is: its an error. [Same if a type is marked abstract] As a matter of interest it may be that the following is useful in an interface: abstract type x = int; and what that means is: the typing is type x; BUT the compiler may use the 'secret' knowledge it's actually an int for optimisation. Something similar to this already happens for classes: you have to give implementation details (data members of a class) in mli files: they're ignored by the typing I think, but needed for code generation The mechanism being discussed here may make it possible to write a large class of programs or libraries without bothering with .mli files, yet still specify the desired interface; avoiding undesirable decoupling. [NOTE: a decoupled interface is still possible and sometimes it is desirable .. just not always] I am trying this out in Felix, I've implemented 'private' and it seems to work as expected... and was immediately very useful (about 20% of all my library functions turned out to be private, and I also make synthesised names private because it might help catch some compiler bugs) ------------------- 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