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 LAA30077; Fri, 19 Jul 2002 11:53:56 +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 LAA30073 for ; Fri, 19 Jul 2002 11:53:55 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from athlon.baretta.com (r-mi214-6a136.tin.it [62.211.4.136]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g6J9rr105114 for ; Fri, 19 Jul 2002 11:53:54 +0200 (MET DST) Received: from baretta.com (localhost.localdomain [127.0.0.1]) by athlon.baretta.com (Postfix) with ESMTP id B38262724F; Fri, 19 Jul 2002 12:01:08 +0200 (CEST) Message-ID: <3D37E364.5060607@baretta.com> Date: Fri, 19 Jul 2002 12:01:08 +0200 From: Alessandro Baretta Organization: Baretta srl -- www.baretta.com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529 X-Accept-Language: it, en MIME-Version: 1.0 To: Jacques Garrigue Cc: caml-list@inria.fr Subject: Re: [Caml-list] Protected methods References: <3D369B89.1030000@baretta.com> <3D36A00A.7010807@gerd-stolpmann.de> <3D36AA1B.2090101@baretta.com> <20020719175002N.garrigue@kurims.kyoto-u.ac.jp> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Jacques Garrigue wrote: >>>You cannot call m from other modules because you cannot create values >>>for the type "protector". >>> >>>Gerd >> >>Effective, definitely, but practical? Is this not supposed >>to be a feature of any general purpose object oriented language? > > > Actually, this seems perfectly practical. > If you have some good reason to "protect" a method, you can do it > cleanly. I would not call adding a fake type a clean solution. It's not idiomatic. A "protected" keyword is cleaner and easier to handle. Although it might be very tricky to implement in a language with type inference. > By the way, ocaml is not a general purpose object-oriented languages, > but a general purpose functional language with object-oriented > features. In particular, encapsulation is supported by the module > system rather than the class system. > Even in object-oriented languages, I've seen heated discussions on > whether using friend classes was good style or not. This is too big an issue for me. I only expressed the need I perceive for a construct to enable different instances of the same class to call methods on their siblings which are not visible to the general public. What I really want is a way to restrict through a type coercion the type of my "autofriendly" class. >>Anyway, for the meantime I'll keep the method public, and >>make sure I don't use it anywhere except where it makes >>sense, and I'll wait for some more insight from the developers. > > > Note that in many cases there are other ways to obtain the expected > behaviour. How about the following pseudocode? Is it sensible/viable? let module M : sig class type public = object end val make_public : unit -> public end = struct class type public = object end class protectd = object (self : #public) end let make_public () -> (new protected :> public) end If this a working alternative, I would prefer over both the protector type and the protected keyword: clean, simple, and idiomatic. > For instance, if only one specific object is supposed to use a method, > you might register a private callback with it rather than the other > way round. > > Jacques Garrigue Hrmmm.... uuuhhh.... yes? What's it mean? Thank you very much, Jacques, for taking time to answer my former post. Alex ------------------- 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