From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id XAA31040; Wed, 21 Aug 2002 23:58:48 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id XAA31041 for ; Wed, 21 Aug 2002 23:58:47 +0200 (MET DST) Received: from smtp.noos.fr (claudel.noos.net [212.198.2.83]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g7LLwk922679 for ; Wed, 21 Aug 2002 23:58:46 +0200 (MET DST) Received: (qmail 47017001 invoked by uid 0); 21 Aug 2002 21:49:38 -0000 Received: from unknown (HELO noos.fr) ([81.65.60.41]) (envelope-sender ) by 212.198.2.83 (qmail-ldap-1.03) with SMTP for ; 21 Aug 2002 21:49:38 -0000 Message-ID: <3D640AF1.C24688A@noos.fr> Date: Wed, 21 Aug 2002 23:49:38 +0200 From: nadji@noos.fr X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.18 i686) X-Accept-Language: en MIME-Version: 1.0 To: caml-list@inria.fr Subject: [Caml-list] polymorphic method question Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, I am puzzled by this behaviour, can a guru explain me ? I have two classes class type ['a] basic = object method foo : 'a end;; class ['a] toto (a:'a) = object method foo = a method bar = () end;; I want to do a class gentoto : class gentoto = object method gen : 'a . 'a -> 'a basic = fun x -> (new toto x :> 'a basic ) end;; But the compiler complains that : Characters 64-98: fun x -> (new toto x :> 'a basic ) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This method has type 'a -> 'a basic which is less general than 'b. 'b -> 'b basic ... but if I do : let newtotoasbasic x = (new toto x :> 'a basic );; class gentoto = object method gen : 'a . 'a -> 'a basic = (* fun x -> (new toto x :> 'a basic ) *) newtotoasbasic end;; The compiler agrees with me ... What is wrong with the first declaration ? Thanks, Nadji ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners