From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p37Llqef012487 for ; Thu, 7 Apr 2011 23:47:52 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArIDAHownk1V2gB5h2dsb2JhbACmJAEBAQoLCQcWJYh5uDwOhV8E X-IronPort-AV: E=Sophos;i="4.63,319,1299452400"; d="scan'208";a="80418760" Received: from emailfrontal2.citycable.ch ([85.218.0.121]) by mail3-smtp-sop.national.inria.fr with SMTP; 07 Apr 2011 23:47:47 +0200 X-Alinto-smtpauth-localdomain: Yes Received: from seldon (91-103-38-56.dynamic.thecloud.net [91.103.38.56]) (Authenticated sender: guillaume.yziquel@citycable.ch) by emailfrontal2.citycable.ch (Postfix) with ESMTPA id B0D9F834C43; Thu, 7 Apr 2011 23:47:45 +0200 (CEST) Received: from yziquel by seldon with local (Exim 4.72) (envelope-from ) id 1Q7x0U-0003Rf-C9; Thu, 07 Apr 2011 23:44:50 +0200 Date: Thu, 7 Apr 2011 23:44:49 +0200 From: Guillaume Yziquel To: Pierre-Alexandre Voye Cc: caml-list Message-ID: <20110407214449.GE4136@localhost> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p37Llqef012487 Subject: Re: [Caml-list] Trouble with subtyping Le Thursday 07 Apr 2011 à 18:48:45 (+0200), Pierre-Alexandre Voye a écrit : > Hi all, I'm working on a lib to modelize a Multi-Agent System where > each agent are driven by a Hierarchical Finite State Machine (HFSM). Hi. > class agent : > object > val mutable birthtime : int > val mutable currentState : agent state option OK. > So, it doesn't want to accept currentState to become a inheritedDwarf > state option and thus, I can't use my inheritedDwarf Not surprising. 'class agent' defines a class, i.e. a piece of code that can be inherited. As of now, the currentState field mentions the type 'agent', so if you inherit from 'agent', currentState field will keep 'agent'. If you want the field to refer to a subclass, do, in the signature: class agent : object ('self) val mutable birthtime : int val mutable currentState : 'self state option ... > Pierre-Alexandre > -- > --------------------- > Isaac Project - [1]http://www.lisaac.org/ -- Guillaume Yziquel