caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Marc Herbert <marc.herbert.1@ml.free.fr>
To: caml-list@yquem.inria.fr
Subject: private methods restricted to self?
Date: Wed, 30 Mar 2005 15:16:37 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.58.0503231720090.7887@fcat> (raw)
In-Reply-To: <6b8a91420503221156e994d7c@mail.gmail.com>

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



  parent reply	other threads:[~2005-03-30 13:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-22 19:18 extending a functional updater implicitly publicizes sub-updater method? Marc Herbert
2005-03-22 19:56 ` [Caml-list] " Remi Vanicat
2005-03-22 23:34   ` wish for something like 'restricted' methods james woodyatt
2005-03-23  5:03     ` [Caml-list] " Jacques Garrigue
2005-03-23  8:22       ` james woodyatt
2005-03-30 13:16   ` Marc Herbert [this message]
2005-03-31  2:30     ` [Caml-list] private methods restricted to self? Jacques Garrigue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.58.0503231720090.7887@fcat \
    --to=marc.herbert.1@ml.free.fr \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).