From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p2HAohL8008598 for ; Thu, 17 Mar 2011 11:50:43 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AksCADaEgU1KfVI0kGdsb2JhbACEPqEHCBQBAQEBCQkNBxQEIak6igI8gh6FGi+IWwEBAwWEZ3cEjF6IeTo X-IronPort-AV: E=Sophos;i="4.63,198,1299452400"; d="scan'208";a="102939811" Received: from mail-ww0-f52.google.com ([74.125.82.52]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 17 Mar 2011 11:50:37 +0100 Received: by wwj40 with SMTP id 40so3392793wwj.9 for ; Thu, 17 Mar 2011 03:50:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=LJ3eiwlr3BLlCHnNhXJg2XB61eRiqscA6gTxlY8ktxw=; b=HYdNjkRhkF+VmGiW1qBciVF+A6P06D5i6FMwQ/HB5G0ZLR4G7HfOE+DKTYKk3yVQ+p 4VAPHoRBim79uH3gHJ0Ojwi7xLyTRjQZMrh7rCN3vV97gL6POHn1CDbps3VRBpGy2gyh yzbk818xZmJdp/BtGx5rcxMV/N611iCWiLwKI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=D/XxLioV21s4rAl9qUs6Ma2ICnY2vtw/g2YEsojB6BGzFoD3FRtzHlb8KBOpCOGbwr jscAUfhUN/KBeeemIffkp7+W5MFii2qgZr1X7Ubwdk/lvw+0kra4cWcTq0+wCK0dAZfJ 9Jvs81sLGH+CzAYKotbMHVA0JDdiTRvaTeUTc= MIME-Version: 1.0 Received: by 10.216.62.77 with SMTP id x55mr1213786wec.59.1300359037548; Thu, 17 Mar 2011 03:50:37 -0700 (PDT) Received: by 10.216.74.5 with HTTP; Thu, 17 Mar 2011 03:50:37 -0700 (PDT) In-Reply-To: <20110317104719.GH22969@localhost> References: <20110317104719.GH22969@localhost> Date: Thu, 17 Mar 2011 11:50:37 +0100 Message-ID: From: Pierre-Alexandre Voye To: caml-list Content-Type: multipart/alternative; boundary=000e0ce0b842837e9c049eab6ee4 Subject: Re: [Caml-list] Re: Define class and sum type in one time --000e0ce0b842837e9c049eab6ee4 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable So, this is impossible ? : class maclasse =3D object(self) val mutable valeur =3D (None : truc option) method getValeur =3D valeur end and truc =3D Machin of (maclasse->int) | Recur of truc;; ? (three attempt to write a correct example of my problem.. All apologies !) 2011/3/17 Guillaume Yziquel > Le Thursday 17 Mar 2011 =C3=A0 11:33:44 (+0100), Pierre-Alexandre Voye a = =C3=A9crit : > > My example would be better with this : > > class machin =3D object(self) > > =C3=82 val mutable valeur =3D (None : truc option) > > =C3=82 method getValeur =3D valeur > > end > > and > > truc =3D Machin of (int->int) | Recur of truc;; > > The object need the type defined > > You cannot declare a class and a type with an 'and'. Either two classes, > or two types. > > Simply declare truc before machin. > > type truc =3D Machin of int -> int | Recur of truc > > class machin =3D object > > val mutable valeur : truc option =3D None > > method getValeur =3D valeur > > end > > -- > Guillaume Yziquel > --=20 --------------------- Isaac Project - http://www.lisaac.org/ --000e0ce0b842837e9c049eab6ee4 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable So, this is impossible=C2=A0 ?=C2=A0=C2=A0 :

class maclasse =3D obje= ct(self)
=C2=A0 val mutable valeur =3D (None : truc option)
=C2=A0 me= thod getValeur =3D valeur
end
and
truc =3D Machin of (maclasse-&g= t;int) | Recur of truc;;

?
(three attempt to write a correct example of my problem.. All apologie= s !)

2011/3/17 Guillaume Yziquel <guillaume.y= ziquel@citycable.ch>
Le Thursday 17 Ma= r 2011 =C3=A0 11:33:44 (+0100), Pierre-Alexandre Voye a =C3=A9crit :
> =C2=A0 =C2=A0My example would be better with this :<= br> > =C2=A0 =C2=A0class machin =3D object(self)
> =C2=A0 =C2=A0=C3=82 =C2=A0val mutable valeur =3D (None : truc op= tion)
> =C2=A0 =C2=A0=C3=82 =C2=A0method getValeur =3D valeur
> =C2=A0 =C2=A0end
> =C2=A0 =C2=A0and
> =C2=A0 =C2=A0truc =3D Machin of (int->int) | Recur of truc;;
> =C2=A0 =C2=A0The object need the type defined

You cannot declare a class and a type with an 'and'. Either t= wo classes,
or two types.

Simply declare truc before machin.

type truc =3D Machin of int -> int | Recur of truc

class machin =3D object

=C2=A0 =C2=A0 =C2=A0 =C2=A0val mutable valeur : truc option =3D None

=C2=A0 =C2=A0 =C2=A0 =C2=A0method getValeur =3D valeur

end

--
=C2=A0 =C2=A0 Guillaume Yziquel



--
----------------= -----
Isaac Project - http://www.lisa= ac.org/
--000e0ce0b842837e9c049eab6ee4--