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 WAA17168; Wed, 6 Jun 2001 22:52:18 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA16913 for caml-list@pauillac.inria.fr; Wed, 6 Jun 2001 22:52:17 +0200 (MET DST) 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 TAA17860 for ; Tue, 5 Jun 2001 19:28:40 +0200 (MET DST) Received: from morgon.inria.fr (morgon.inria.fr [128.93.8.33]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f55HSZr12461; Tue, 5 Jun 2001 19:28:35 +0200 (MET DST) Received: (from remy@localhost) by morgon.inria.fr (8.9.3/8.9.3) id PAA10559; Tue, 5 Jun 2001 15:06:27 +0200 To: Sarino Suon Cc: caml-list@inria.fr Subject: Re: [Caml-list] Confused: The example on page 48 where (self :> c) does not work References: From: Didier Remy Date: 05 Jun 2001 15:06:26 +0200 In-Reply-To: Sarino Suon's message of "Thu, 31 May 2001 14:07:56 -0500 (CDT)" Message-ID: X-Mailer: Gnus v5.7/Emacs 20.4 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Sarino Suon writes: Dear Sarino, > I'm trying to understand the example on page 48 of the Ocaml release 3.00 > documentation (PDF format). This was to show the case where omitting the > domain of a coercion does not work. Here's the example: > > class virtual c = > object > method virtual m:c > end;; > > class c' = > object (self) inherit c > method m = (self :> c) (* !!! *) > method m' = 1 > end;; > > I don't understand the explanation why the coercion would cause a problem, This was true in a previous version of the language. The mecanism for semi-implicit coercions (_ :> _) has been slightly changed in the current version of the langage, so as to handle more common cases. Unfortunately, the manual has not been changed, acccordingly. (This has already be pointed out to me, and it will be fixed in the next version.) The new mechanism handle more common cases, but still does not accept all of them. For instance, with class type c1 = object ('a) method m : 'a end;; class type c2 = object method m : c2 end;; class c = object method m = {< >} method n = 0 end;; Class types c1 and c2 differ, but object type c1 and c2 are equal. The following coercion is accepted: (new c' :> c1);; However, the following, although correct, is rejected (new c' :> c2);; In this case, the explicit (_ : _ :> _) form should be used: (new c' : c' :> c2);; -Didier ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr