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 BAA00294; Mon, 15 Jul 2002 01:52:07 +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 BAA00182 for ; Mon, 15 Jul 2002 01:52:06 +0200 (MET DST) Received: from smtp.noos.fr (verlaine.noos.net [212.198.2.73]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g6ENauf24837 for ; Mon, 15 Jul 2002 01:37:04 +0200 (MET DST) Received: (qmail 32145345 invoked by uid 0); 14 Jul 2002 23:16:54 -0000 Received: from unknown (HELO noos.fr) ([81.65.61.57]) (envelope-sender ) by 212.198.2.73 (qmail-ldap-1.03) with SMTP for ; 14 Jul 2002 23:16:54 -0000 Message-ID: <3D320665.AC5539CD@noos.fr> Date: Mon, 15 Jul 2002 01:16:53 +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 methods Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello, While playing with the current cvs version of ocaml (3.04+15), several questions came to me concerning the semantics of polymorphic methods. For example : # class c = object method ~m: 'a . unit -> 'a -> 'a = fun _ x -> x end;; class c : object method m : unit -> 'a -> 'a end # let f = (new c)#m ();; val f : '_a -> '_a = Shouldn't the type of f be : 'a -> 'a ? (Would it be sound/implementable/easy to add ?) Second question: # class ['a] d = object method m: 'a -> 'a = fun x -> x end;; class ['a] d : object method m : 'a -> 'a end # class subd = object method ~m: 'a. 'a -> 'a = fun x -> x end;; class subd : object method m : 'a -> 'a end # let v = (new subd :> 'a d);; Characters 9-17: let v = (new subd :> 'a d);; ^^^^^^^^ This expression cannot be coerced to type 'a d = < m : 'a -> 'a >; it has type subd = < m : 'b. 'b -> 'b > but is here used with type 'a d Or even the easier : # class d' = object method m x = x + 0 end;; class d' : object method m : int -> int end # let v' = (new subd :> d');; Characters 10-18: let v' = (new subd :> d');; ^^^^^^^^ This expression cannot be coerced to type d' = < m : int -> int >; it has type subd = < m : 'a. 'a -> 'a > but is here used with type d' But the type ('b. 'b -> 'b) is more general than ('a -> 'a) or (int -> int), no ? Can someone give me some hints why I can't coerce subd ? Btw, thanks for the upcoming release, it seems _really_ excellent ! 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