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 DDB59BC84 for ; Wed, 30 Mar 2005 15:17:01 +0200 (CEST) Received: from postfix4-1.free.fr (postfix4-1.free.fr [213.228.0.62]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j2UDH1Hu026737 for ; Wed, 30 Mar 2005 15:17:01 +0200 Received: from [192.168.0.60] (lns-vlq-37-lyo-82-253-101-87.adsl.proxad.net [82.253.101.87]) by postfix4-1.free.fr (Postfix) with ESMTP id 52C492E24FF for ; Wed, 30 Mar 2005 15:17:01 +0200 (CEST) Date: Wed, 30 Mar 2005 15:16:37 +0200 (CEST) From: Marc Herbert X-X-Sender: mherbert@fcat To: caml-list@yquem.inria.fr Subject: private methods restricted to self? In-Reply-To: <6b8a91420503221156e994d7c@mail.gmail.com> Message-ID: References: <6b8a91420503221156e994d7c@mail.gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=iso-8859-1 Content-Transfer-Encoding: 8BIT X-Miltered: at nez-perce with ID 424AA6CD.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; implicitly:01 ocaml:01 surprising:01 val:01 val:01 implicitly:01 ocaml:01 jerome:01 vouillon's:01 einfach:98 glich:98 einstein:98 wrote:01 interfaces:01 reasoning: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: On Tue, 22 Mar 2005, Remi Vanicat wrote: > > I don't understand why my private subupdater is "made public implicitly" > In ocaml, you can only call a private method on self. super#forward > is not self, so you cannot call the color_forward method on it. Indeed! This other example, without any subclass, is even more surprising: class functional_point = object(self) val x = 0 val y = 0 method private bump_x = {< x = x + 1 >} method private bump_y = {< y = y + 1 >} method private bump_both = self#bump_x#bump_y end Warning: the following private methods were made public implicitly: bump_y > In ocaml, you can only call a private method on self. super#forward > is not self, so you cannot call the color_forward method on it. Thanks a lot for the reasoning. But I still don't get the rationale. Could I find the answer in Jerôme Vouillon's "an object calculus with views"? Elsewhere? Thanks in advance. About the reference documentation --------------------------------- However ignorant are my questions above, I nevertheless think the documentation is not clear about this whole issue. To find this self#private restriction you have to dive into section '6.9.2 Class expressions'. Unfortunately you may never go so far since the more user-friendly '3.6 Private methods' section gives the less restrive, more usual definition: "Private methods are methods that do not appear in object interfaces. They can only be invoked from other methods of the same object." which made me think I knew enough about 'private' and prevented me to look further. Section '6.9.1 class types' also states: "The flag private indicates whether the method can be accessed from outside the class." Coming from another OO-language, it's hard to understand "outside" as "restricted to self". So as a conclusion I find the manual at least confusing on this, if not erroneous. Is it? By the way, maybe some extra comment in the Warning message above would not hurt either. -- So einfach wie möglich. Aber nicht einfacher -- Albert Einstein