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 JAA29638; Sun, 21 Jul 2002 09:55:23 +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 JAA29713 for ; Sun, 21 Jul 2002 09:55:22 +0200 (MET DST) Received: from relay.rinet.ru (relay.rinet.ru [195.54.192.35]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g6L7tKj20060 for ; Sun, 21 Jul 2002 09:55:21 +0200 (MET DST) Received: (from uucp@localhost) by relay.rinet.ru (8.11.6/8.11.6) with UUCP id g6L7tKt29957 for caml-list@inria.fr; Sun, 21 Jul 2002 11:55:20 +0400 (MSD) X-Envelope-To: caml-list@inria.fr Received: from dialin1.stormoff (ROVER1) [192.168.0.129] by stormoff with esmtp (Exim 3.12 #1 (Debian)) id 17WBW4-0003e8-00; Sun, 21 Jul 2002 11:52:33 +0400 X-Comment-To: Alessandro Baretta To: caml-list@inria.fr Subject: Re: [Caml-list] Protected methods References: <3D369B89.1030000@baretta.com> <3D39F829.6060307@baretta.com> From: Dmitry Bely Date: Sun, 21 Jul 2002 11:52:22 +0400 In-Reply-To: <3D39F829.6060307@baretta.com> (Alessandro Baretta's message of "Sun, 21 Jul 2002 01:54:17 +0200") Message-ID: User-Agent: Gnus/5.090005 (Oort Gnus v0.05) XEmacs/21.4 (Common Lisp (Windows [3]), i586-pc-win32) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Alessandro Baretta writes: >> Do not private Ocaml methods have in fact "protected" C++ semantics? They >> cannot be called directly but can be used in methods of inherited >> classes... >> - Dmitry Bely > > I thought so, too. I made several atttempts, and the compiler seemed > to reject all of them. Let me see if I can cook up a quick example. > > # class a = object method private m : unit = (new a) # m end;; > The expression "new a" has type a = < > but is used with type > < m : unit; .. > > Only the second object type has a method m That's because Ocaml private methods can only be applied to the "self" or "super" object, not to other class instances. Obviously, an object hierarchy has nothing to do with a class hierarchy (C++'s "private" and "protected" just ignore existence of the first one, and IMHO that is not good). But why do you need to call other instance's private/protected methods? Maybe you should slightly change your design? Could you roughly describe your task? - Dmitry Bely ------------------- 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