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 FAA17437; Sat, 25 May 2002 05:55:58 +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 FAA16981 for ; Sat, 25 May 2002 05:55:57 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g4P3ttf14191 for ; Sat, 25 May 2002 05:55:56 +0200 (MET DST) Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3/3.7W) with ESMTP id MAA13223; Sat, 25 May 2002 12:55:41 +0900 (JST) To: alex@baretta.com Cc: caml-list@inria.fr Subject: Re: [Caml-list] What about polymorphic methods? In-Reply-To: <3CEF08ED.80407@baretta.com> References: <3CEF08ED.80407@baretta.com> X-Mailer: Mew version 1.94.2 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20020525125530P.garrigue@kurims.kyoto-u.ac.jp> Date: Sat, 25 May 2002 12:55:30 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Alessandro Baretta > method left_iter : ('a -> 'b) -> 'b list > method right_iter : ('a -> 'c) -> 'c list > > Is there any way, then, to define polymorphic versions of > the two iterators? Indeed, iterators are one of the major reasons to have polymorphic methods in ocaml (the other one being implicit subtyping of arguments). They are already in CVS, and will be present in ocaml 3.05. With the CVS version, you would have to write method left_iter : 'b. ('a -> 'b) -> 'b list = fun f -> ... method right_iter : 'b. ('a -> 'b) -> 'b list = fun f -> ... Of course, 'b is no longer a parameter of the class. Note that polymorphic methods can only be called on objects whose type is (at least partially) known, so you may have to add a few extra type annotations to your code. Jacques Garrigue ------------------- 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