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 JAA22955; Fri, 21 Dec 2001 09:40:48 +0100 (MET) 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 JAA22417 for ; Fri, 21 Dec 2001 09:40:47 +0100 (MET) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id fBL8ejP07446 for ; Fri, 21 Dec 2001 09:40:46 +0100 (MET) Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3/3.7W) with ESMTP id RAA19766; Fri, 21 Dec 2001 17:40:36 +0900 (JST) To: patrick@watson.org Cc: caml-list@inria.fr Subject: Re: [Caml-list] Objects and private methods In-Reply-To: <20011221001434.V91723-100000@fledge.watson.org> References: <20011221140658Z.garrigue@kurims.kyoto-u.ac.jp> <20011221001434.V91723-100000@fledge.watson.org> X-Mailer: Mew version 1.94.2 on Emacs 20.7 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20011221174035L.garrigue@kurims.kyoto-u.ac.jp> Date: Fri, 21 Dec 2001 17:40:35 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Patrick M Doane > > You cannot convert something from private to public through a coercion > > (this is different from forcing it with an annotation). This is > > because the values are actually different: a private method and a > > public method have different internal representations. > > Are there any papers that I could read over that would give a better sense > for the internal representations? That might help me understand some of > these limitations better. I don't think so, but books like Abadi&Cardelli's Types for Objects would give you an insight on what is safe and what is not. > > On the other hand, you can hide a method through coercions. > > > > class a_impl = object (self) > > method get_b = (self :> b) > > method b = () > > end > > let new_a = (new a_impl :> a) > > Thanks! What then are the advantages to using an annotation instead of a > coercion for signature matching? For example, with a hypothetical syntax > like this: > > class a_impl :> a = object (self) > method get_b = (self :> b) > method b = () > end You can only coerce from type to type, not from signature to signature. Otherwise you would be able to hide a method, and then redefine it with the same name but another type. Such inheritance patterns are not type safe, so you are not allowed to hide a public method at the class level, only at the expression level, where it is safe. Jacques Garrigue ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr