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.2 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id ECA06BBAF for ; Wed, 8 Apr 2009 13:36:40 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAMMo3EnVuiYS/2dsb2JhbADOGQeDdAY X-IronPort-AV: E=Sophos;i="4.39,344,1235948400"; d="scan'208";a="24198081" Received: from solaria.dimino.org ([213.186.38.18]) by mail2-smtp-roc.national.inria.fr with ESMTP; 08 Apr 2009 13:36:40 +0200 Received: from aurora (localhost.localdomain [127.0.0.1]) by solaria.dimino.org (Postfix) with ESMTP id 530988004C; Wed, 8 Apr 2009 13:36:40 +0200 (CEST) Received: by aurora (Postfix, from userid 1000) id 3ACDD44769; Wed, 8 Apr 2009 13:36:40 +0200 (CEST) Subject: Re: [Caml-list] storing object in record From: =?ISO-8859-1?Q?J=E9r=E9mie?= Dimino To: Michael Cc: caml-list@yquem.inria.fr In-Reply-To: <200904081229.03099.micha-1@fantasymail.de> References: <200904080936.16263.micha-1@fantasymail.de> <1239177288.6630.41.camel@localhost.localdomain> <200904081229.03099.micha-1@fantasymail.de> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Date: Wed, 08 Apr 2009 13:36:39 +0200 Message-Id: <1239190599.6630.75.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.24.5 X-Spam: no; 0.00; 0200,:01 forall:01 inlined:01 val:01 abbreviation:01 2009:98 unbound:01 caml-list:01 constraint:01 constraint:01 match:02 objects:02 constraints:03 unit:03 let:03 Le mercredi 08 avril 2009 =C3=A0 12:29 +0200, Michael a =C3=A9crit : > > There is no value of type: forall 'a. #baseclass as 'a. >=20 > is this similar? : >=20 > type 'a xx =3D 'a constraint 'a =3D < asBase: baseObject; .. > ;; >=20 > (why does: type 'a xx =3D < asBase: baseObject; ..> as 'a not work inst= ead? ) No, [type 'a xx =3D 'a constraint 'a =3D < asBase: baseObject; .. >] just means that ['a] must match [< asBase : baseObject; .. >]. Actually constraints are just inlined: # type 'a t =3D 'a constraint 'a =3D _ * _;; type 'a t =3D 'a constraint 'a =3D 'b * 'c # let f (x : 'a t) =3D ();; val f : ('a * 'b) t -> unit =3D If you write [type 'a xx =3D < asBase: baseObject; ..>] (with or without [as 'a]), then you have an unbound variable in the type definition (the [..]). > type 'a r =3D { state: 'a xx };; >=20 > gives: > type 'a r =3D { state : 'a xx; } constraint 'a =3D < asBase : baseObject;= .. > >=20 >=20 > so the record holds objects with an asBase method and more, isn't this th= e=20 > same as #baseObject? [#baseObject] is an abbreviation for [< asBase : baseObject; .. >]. J=C3=A9r=C3=A9mie