From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA27794 for caml-redistribution; Thu, 21 May 1998 14:31:11 +0200 (MET DST) 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 RAA26545 for ; Wed, 20 May 1998 17:00:04 +0200 (MET DST) Received: from tcs.inf.tu-dresden.de (tcs.inf.tu-dresden.de [141.76.75.119]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id RAA20566 for ; Wed, 20 May 1998 17:00:02 +0200 (MET DST) Received: from ithif18.inf.tu-dresden.de (ithif18 [141.76.75.118]) by tcs.inf.tu-dresden.de (8.8.3/8.8.3) with SMTP id QAA06741 for ; Wed, 20 May 1998 16:59:34 +0200 (MET DST) Received: by ithif18.inf.tu-dresden.de (SMI-8.6/SMI-SVR4) id RAA19129; Wed, 20 May 1998 17:00:12 +0200 Date: Wed, 20 May 1998 17:00:12 +0200 Message-Id: <199805201500.RAA19129@ithif18.inf.tu-dresden.de> From: Hendrik Tews MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: caml-list@inria.fr Subject: Subtype problem X-Mailer: VM 6.34 under Emacs 19.34.1 Sender: weis Hi, could somebody tell me, why -------------------------Version 1--------------------------- class point x = val mutable x = (x : int) method x = x method move (i : int) = {< x = x + i >} end;; class colored_point x c = val mutable x = (x : int) val color = (c : int) method x = x method move (i : int) = {< x = x + i >} method color = color end;; let p = ((new colored_point 2 1 :> point) : point) -------------------------Version 1--------------------------- compiles without problem, while -------------------------Version 2--------------------------- class point x = val mutable x = (x : int) method x = x method move (i : int) = Some {< x = x + i >} end;; class colored_point x c = val mutable x = (x : int) val color = (c : int) method x = x method move (i : int) = Some {< x = x + i >} method color = color end;; let p = ((new colored_point 2 1 :> point) : point) -------------------------Version 2--------------------------- produces an error? (The only difference is the move method, which delivers an option in version 2). The error message is -------------------------Error------------------------------- This expression cannot be coerced to type point = < x : int; move : int -> point option >; it has type colored_point = < x : int; move : int -> colored_point option; color : int > but is here used with type < x : int; move : int -> point option; color : int > Type colored_point = < x : int; move : int -> colored_point option; color : int > is not compatible with type point = < x : int; move : int -> point option > -------------------------Error------------------------------- Bye, Hendrik