caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Dmitry Bely <dbely@mail.ru>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Protected methods
Date: Sun, 21 Jul 2002 11:52:22 +0400	[thread overview]
Message-ID: <adoljz61.fsf@mail.ru> (raw)
In-Reply-To: <3D39F829.6060307@baretta.com> (Alessandro Baretta's message of "Sun, 21 Jul 2002 01:54:17 +0200")

Alessandro Baretta <alex@baretta.com> 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


  reply	other threads:[~2002-07-21  7:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-18 10:42 Alessandro Baretta
2002-07-18 11:01 ` Gerd Stolpmann
2002-07-18 11:44   ` Alessandro Baretta
2002-07-19  8:50     ` Jacques Garrigue
2002-07-19 10:01       ` Alessandro Baretta
2000-07-20  0:46         ` Jacques Garrigue
2002-07-20  7:41           ` Alessandro Baretta
2002-07-20  1:31         ` Jacques Garrigue
2002-07-20  7:48           ` Alessandro Baretta
2002-07-20 22:48 ` Dmitry Bely
2002-07-20 23:08   ` Brian Smith
2002-07-22  3:37     ` OCaml's OO design " Jacques Garrigue
2002-07-22  4:20       ` John Prevost
2002-07-20 23:54   ` Alessandro Baretta
2002-07-21  7:52     ` Dmitry Bely [this message]
2002-07-21 13:14       ` Alessandro Baretta

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=adoljz61.fsf@mail.ru \
    --to=dbely@mail.ru \
    --cc=caml-list@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).