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.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 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 7EEA0BC6B for ; Thu, 10 Jan 2008 14:04:43 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAAinhUeFBoIFh2dsb2JhbACQHwEBAQgKKZkr X-IronPort-AV: E=Sophos;i="4.24,266,1196636400"; d="scan'208";a="21089176" Received: from rabbit.math.nagoya-u.ac.jp ([133.6.130.5]) by mail4-smtp-sop.national.inria.fr with ESMTP; 10 Jan 2008 14:04:42 +0100 Received: from localhost (rabbit-172 [172.16.254.254]) by rabbit.math.nagoya-u.ac.jp (8.12.11/3.7W) with ESMTP id m0ACuwrm024175; Thu, 10 Jan 2008 21:56:58 +0900 (JST) Date: Thu, 10 Jan 2008 21:56:58 +0900 (JST) Message-Id: <20080110.215658.2004149870.garrigue@math.nagoya-u.ac.jp> To: axel.poigne@iais.fraunhofer.de Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Type checking question From: Jacques GARRIGUE In-Reply-To: References: <9f09a07a0801100005n5061a656ubbf7620e48e298ee@mail.gmail.com> X-Mailer: Mew version 4.2 on Emacs 21.4 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; fraunhofer:01 val:01 mutable:01 val:01 extensible:01 defines:01 caml-list:01 inherit:01 int:01 int:01 checking:02 garrigue:03 garrigue:03 subclass:03 jacques:03 From: Axel Poign=E9 > why does this work [...] > #class yyy (x:int) =3D > object(self) > inherit xxx x > method set y =3D _x <- y > end;; > class yyy : int -> > object val mutable _x : int method get : int method set : int -> u= nit end > #let yy =3D new yyy 8;; > val yy : yyy > = > I would expect that yy is of not type yyy =3D int -> ... The confusion is due to the fact a class definition actually defines 4 = things: * the class itself, whose type is displayed * a class type with same name, which is the displayed type _without_ th= e parameters (here, without int ->) * an object type with same name, which is constructed from the public methods of the class type * an extensible object type #yyy, which is unifiable with any subclass = of yyy. The yyy in "new yyy" is the class, but the one in "val yy : yyy" is the object type. Jacques Garrigue