From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 63C32BC84 for ; Wed, 23 Mar 2005 06:03:25 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j2N53OeN023351 for ; Wed, 23 Mar 2005 06:03:24 +0100 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 GAA19287 for ; Wed, 23 Mar 2005 06:03:24 +0100 (MET) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j2N53MHJ013257 for ; Wed, 23 Mar 2005 06:03:23 +0100 Received: from localhost (suiren [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.13.1/8.13.1) with ESMTP id j2N53Kwv017291; Wed, 23 Mar 2005 14:03:21 +0900 (JST) Date: Wed, 23 Mar 2005 14:03:12 +0900 (JST) Message-Id: <20050323.140312.78769966.garrigue@math.nagoya-u.ac.jp> To: jhw@wetware.com Cc: caml-list@inria.fr Subject: Re: [Caml-list] wish for something like 'restricted' methods From: Jacques Garrigue In-Reply-To: <1b4c73f40a9fe87d2bcf34c14afa1e74@wetware.com> References: <6b8a91420503221156e994d7c@mail.gmail.com> <1b4c73f40a9fe87d2bcf34c14afa1e74@wetware.com> X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 4240F89C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 4240F89A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 woodyatt:01 jhw:01 wetware:01 explicitely:01 jerome:01 ocaml:01 binary:01 ocaml:01 sig:01 val:01 val:01 struct:01 researched:98 vouillon:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: From: james woodyatt > I'd like to be able to define a method that isn't public, but also > isn't private. I don't know what to call this method qualification. > For the purposes of this discussion *only*, I'll pick a proposed word > to reserve: restricted. > > A "restricted" method would be one that may only be invoked within the > methods of objects constrained to the type of any classtype-def in > their classtype-definition. Reading the remainder of your mail, I couldn't understand your notion of restricted method. Maybe it would be better if you give an exemple of situation where you need this new expressiveness, rather than explicitely define a new notion, as there may be several solutions to your problem. > Have ideas along these lines been considered or even researched? I > realize that there are ways to get along without a feature like this, > and they're not that bad all things considered. (Example: use public > methods with abstract types in the module signature, and delegate > through them to private methods with concrete types.) This > "restricted" method type would just be a convenient way of allowing the > programmer to express this intent within the language itself. Jerome Vouillon (the original implementor of the ocaml object system) wrote a paper about using views to allow arbitrary hiding of methods. Combining subsumption and binary methods: An object calculus with views In Proceedings of the 28th ACM Conference on Principles of Programming Languages, pages 290\u2013303, 2001 This may be related to what you want. However there is no plan to include views in ocaml. On the other hand, I have just extended the ocaml type system to allow the use of private structural types, i.e. abstract types where you still allow access to some methods. Then you can write something like this: module M : sig type p = private < m: int; .. > type q = private < g: int; .. > val new_p : unit -> p val new_q : p -> q end = struct class p = object method m = 3 method f (q : q) = q#h end and q (x : p) = object (self) method g = x#f (self :> q) method h = 7 end let new_p () = new p let new_q = new q end where f and h are "friend" methods. Jacques Garrigue