From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id CFE88BBCA for ; Tue, 1 Apr 2008 04:42:50 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAE8+8UeCNhAB/2dsb2JhbACqTg X-IronPort-AV: E=Sophos;i="4.25,584,1199660400"; d="scan'208";a="24426513" Received: from kurims.kurims.kyoto-u.ac.jp ([130.54.16.1]) by mail4-smtp-sop.national.inria.fr with ESMTP; 01 Apr 2008 04:42:49 +0200 Received: from localhost (orion [130.54.16.5]) by kurims.kurims.kyoto-u.ac.jp (8.13.8/8.13.8) with ESMTP id m312gi5e021067; Tue, 1 Apr 2008 11:42:44 +0900 (JST) Date: Tue, 01 Apr 2008 11:42:34 +0900 (JST) Message-Id: <20080401.114234.146324100.garrigue@math.nagoya-u.ac.jp> To: rathereasy@gmail.com Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] type error From: Jacques Garrigue In-Reply-To: References: X-Mailer: Mew version 4.2 on Emacs 22.1 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; abbreviation:01 unifying:01 exception:01 caml-list:01 inherit:01 coerce:02 coerce:02 defined:02 defined:02 covariant:02 garrigue:03 garrigue:03 jacques:03 jacques:03 nagoya-u:04 From: "Jacques Le Normand" > thanks for all the help so far; it's been very educational > there's a type error I can't get my head around: > > > class a = > object > end > > and b = > object > inherit a > method d (e : b) = (e :> a) > end > > > gives the error: > > The abbreviation b expands to type < d : b -> a > but is used with type < > > > why is this? You cannot coerce to a type that is not yet (fully) defined. In practice, what happens is that (e :> a) is just interpreted as (e : a), so that you are unifying a and b, with the above error. As an exception to the above rule, you can coerce self toward the currently defined class (i.e. coerce self to a inside a), but only if self is covariant in itself. Here you coerce b to a inside b, so this doesn't apply. Jacques Garrigue