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 NAA08379; Thu, 18 Jul 2002 13:01:34 +0200 (MET DST) 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 NAA08375 for ; Thu, 18 Jul 2002 13:01:33 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from p5080ECCF.dip.t-dialin.net (p5080ECCF.dip.t-dialin.net [80.128.236.207]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g6IB1WT26532 for ; Thu, 18 Jul 2002 13:01:32 +0200 (MET DST) Received: from hera.ffm.npc.de (hera.ffm.npc.de [192.168.130.8]) by p5080ECCF.dip.t-dialin.net (Postfix STYX NPC GmbH) with ESMTP id 8EF0D78E0; Thu, 18 Jul 2002 13:01:31 +0200 (CEST) Received: from gerd-stolpmann.de (ares.ffm.npc.de [192.168.130.32]) by hera.ffm.npc.de (Postfix HERA NPC GmbH) with ESMTP id 068F45683; Thu, 18 Jul 2002 13:01:30 +0200 (CEST) Message-ID: <3D36A00A.7010807@gerd-stolpmann.de> Date: Thu, 18 Jul 2002 13:01:30 +0200 From: Gerd Stolpmann User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Alessandro Baretta Cc: Ocaml Subject: Re: [Caml-list] Protected methods References: <3D369B89.1030000@baretta.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Alessandro Baretta wrote: > I'm trying to get the semantics of protected methods of C++. I have a > class with a method that is not meaningful for the outside world, but > different instances of this class should be able to invoke this method > on one another. > > I need something like the following pseudocode: > > class a = > object > method protected m = ... > method m2 (obj:a) = a # m > end > > I understand this can be obtained by creating a container module for > class a and restricting the type of a through the module signature. I > read the manual but was unable to figure out the syntax to do this. > Would anyone be so kind as to lend a hand? No, you cannot restrict the type of classes by signatures. The only way I know to protect a method is to define an opaque type that is hidden by the signature, e.g. sample.ml: type protector = unit class a = object method m () = ... ... end sample.mli: type protector class a : object method m : protector -> XXX ... end You cannot call m from other modules because you cannot create values for the type "protector". Gerd -- ------------------------------------------------------------ Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de ------------------------------------------------------------ ------------------- 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