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 SAA18605; Mon, 15 Jul 2002 18:24:31 +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 SAA18879 for ; Mon, 15 Jul 2002 18:24:30 +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 g6FGOTj03238 for ; Mon, 15 Jul 2002 18:24:29 +0200 (MET DST) Received: (qmail 29115827 invoked by uid 0); 15 Jul 2002 16:24:23 -0000 Received: from unknown (HELO noos.fr) ([81.65.61.57]) (envelope-sender ) by 212.198.2.83 (qmail-ldap-1.03) with SMTP for ; 15 Jul 2002 16:24:23 -0000 Message-ID: <3D32F736.E0A88673@noos.fr> Date: Mon, 15 Jul 2002 18:24:22 +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: Jacques Garrigue CC: caml-list@inria.fr Subject: Re: [Caml-list] polymorphic methods References: <3D320665.AC5539CD@noos.fr> <20020715100504O.garrigue@kurims.kyoto-u.ac.jp> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Jacques Garrigue wrote: > > # let f = (new c)#m ();; > > val f : '_a -> '_a = > > Unsound. RTFM (polymorphism restricted to values) > Try "let f x = (new c)#m () x" > Oups, sorry. I did'nt recognize this classical problem ... In fact this example was an attempt to simplify my next question, but I can see now that they are not related. > But I don't see why you need (). > You're right. It was there for historical reasons and I had not realized I did'nt need an argument anymore. > > Can someone give me some hints why I can't coerce subd ? > > Sorry, but there is no handling of instanciation via subtyping. > Currently subtyping and instanciation are orthogonal concepts: you > cannot subtype in an .mli, and you cannot instanciate an > explicitly polymorphic type when subtyping. That's a shame because if one tries to use objects for manipulating lists : # exception Emptylist class type ['a] olist = object method hd : 'a method tl : 'a olist end class nil = object method ~hd: 'a . 'a = raise Emptylist method ~tl: 'a . 'a olist = raise Emptylist end let objnil = (new nil :> 'a olist);; Characters 14-21: let objnil = (new nil :> 'a olist);; ^^^^^^^ This expression cannot be coerced to type 'a olist = < hd : 'a; tl : 'a olist >; it has type nil = < hd : 'b. 'b; tl : 'c. 'c olist > but is here used with type < hd : 'a; tl : 'a #olist >. This simple coercion was not fully general. Consider using a double coercion. Too bad. Also this is the first time I get this error message. Does it mean that I have to try something like (a : b :> c) ? If not, what is a double coercion, and can you give a case where is it needed ? > > I believe it's correct, but you won't make me write the code without a > proof :-) This is why I like Ocaml :) ------------------- 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