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 DAA16053; Sat, 25 May 2002 03:41:16 +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 DAA15812 for ; Sat, 25 May 2002 03:41:15 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from athlon.baretta.com (r-mi214-6a71.tin.it [62.211.4.71]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g4P1fBf12626 for ; Sat, 25 May 2002 03:41:12 +0200 (MET DST) Received: from baretta.com (localhost.localdomain [127.0.0.1]) by athlon.baretta.com (Postfix) with ESMTP id 7FBEE273A7 for ; Sat, 25 May 2002 05:45:49 +0200 (CEST) Message-ID: <3CEF08ED.80407@baretta.com> Date: Sat, 25 May 2002 05:45:49 +0200 From: Alessandro Baretta Organization: Baretta srl -- www.baretta.com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0rc1) Gecko/20020417 X-Accept-Language: it, en MIME-Version: 1.0 To: Ocaml Subject: [Caml-list] What about polymorphic methods? Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I am writing a very simple class to handle bidirectional (bidi) lists in an object-functional manner. I have come up with a curious problem. The following text is the toplevel's output when it is passed my code. # type 'a bidi = Elem of 'a bidi * 'a * 'a bidi | Null class ['a, 'b, 'c] bidi_list : 'a list -> object method head : 'a bidi method left_iter : ('a -> 'b) -> 'b list method right_iter : ('a -> 'c) -> 'c list method tail : 'a bidi val first : 'a bidi val last : 'a bidi end # new bidi_list [1;2;3;4;5];; - : (int, '_a, '_b) bidi_list = The basic idea is that I want to convert a value with type 'a list to a value belonging to class ['a] bidi_list. Now, if I leave 'b and 'c out of the parameter list my code refuses to compile, but even when I add 'b and 'c as type parameters, the type checker specializes them to '_b and '_c, which are not polymorphic. Is there any way, then, to define polymorphic versions of the two iterators? Alex Baretta ------------------- 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