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 JAA14853; Sat, 20 Jul 2002 09:41:03 +0200 (MET DST) 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 JAA14851 for ; Sat, 20 Jul 2002 09:41:02 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from athlon.baretta.com (r-mi214-6a94.tin.it [62.211.4.94]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g6K7f0j07663 for ; Sat, 20 Jul 2002 09:41:00 +0200 (MET DST) Received: from baretta.com (localhost.localdomain [127.0.0.1]) by athlon.baretta.com (Postfix) with ESMTP id 7F2F6273C4; Sat, 20 Jul 2002 09:48:19 +0200 (CEST) Message-ID: <3D3915C3.5030902@baretta.com> Date: Sat, 20 Jul 2002 09:48:19 +0200 From: Alessandro Baretta Organization: Baretta srl -- www.baretta.com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529 X-Accept-Language: it, en MIME-Version: 1.0 To: Jacques Garrigue , ocaml Subject: Re: [Caml-list] Protected methods References: <3D36AA1B.2090101@baretta.com> <20020719175002N.garrigue@kurims.kyoto-u.ac.jp> <3D37E364.5060607@baretta.com> <20020720103117U.garrigue@kurims.kyoto-u.ac.jp> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Jacques Garrigue wrote: > From: Alessandro Baretta > >>How about the following pseudocode? Is it sensible/viable? >> >>let module M : sig >> class type public = object end >> val make_public : unit -> public >>end = struct >> class type public = object end >> class protectd = >> object (self : #public) >> >> >> end >> let make_public () -> (new protected :> public) >>end > > > Actually, after a more thorough look at your code, I'm not sure of > what you're trying to achieve with it. Applied directly, it seems > that it would give you no more than private methods: you can not use > them outside of the class. Allowing different instances of a class to invoke protected methods on each other, without these methods being exported to the general public. > And I've found a better idiom, that should do about anything you want. Success! :-) > module M : sig > type hidden > class type public = object < public methods > method full : hidden end > val make_public : unit -> public > class virtual protected : object ('a) > < public methods > > < protected methods > > method full : 'a > end > end = struct > class protected = object (self) > < public methods > > < protected methods > > method full = self > end > type hidden = protected > class type public = object < public methods > method full : hidden end > let make_public () = (new protected : protected :> public) > end I publicly bow to another Jedi camler. May inheritance and subtyping be with you. Alex ------------------- 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