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 MAA15477; Sat, 22 Mar 2003 12:22:45 +0100 (MET) 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 MAA17448 for ; Sat, 22 Mar 2003 12:22:44 +0100 (MET) Received: from mail2.bluewin.ch (mail2.bluewin.ch [195.186.4.73]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h2MBMhf12249 for ; Sat, 22 Mar 2003 12:22:44 +0100 (MET) Received: from epfl.ch (195.186.198.148) by mail2.bluewin.ch (Bluewin AG 6.7.016) id 3E674A7B001F545D for caml-list@inria.fr; Sat, 22 Mar 2003 11:22:43 +0000 Message-ID: <3E7C4784.6000901@epfl.ch> Date: Sat, 22 Mar 2003 12:22:44 +0100 From: =?ISO-8859-1?Q?S=E9bastien_Briais?= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: [Caml-list] About polymorphic methods and recursive classes Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Spam: no; 0.00; ledit:01 3.06:01 instantiate:01 encode:01 ocaml:01 caml:01 inherit:01 int:01 toplevel:01 polymorphic:01 objects:02 classes:03 recursive:03 nil:03 object:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello, (I tried to send this mail yesterday, but apparently it did not work. So I send it again:) I tried to encode lists with objects. I defined a class list which is virtual and that contains only a visit method which is polymorphic. I have defined also a virtual class visitor to visit the lists. The ocaml toplevel indicated me there was an error in my piece of code but since I didn't understand the error message, I have simplified my piece in order to understand which part is not accepted by ocaml. Here is the simplified code > ledit ocaml Objective Caml version 3.06 # class virtual ['a] visitor = object method virtual caseNil : 'a end and virtual int_list = object method virtual visit : 'a.('a visitor -> 'a) end ;; class virtual ['a] visitor : object method virtual caseNil : 'a end class virtual int_list : object method virtual visit : 'a visitor -> 'a end # class nil = object inherit int_list method visit v = v#caseNil end ;; This expression has type 'a visitor It has no method caseNil This is this last message that I do not understand. I tried also to remove the 'and' in the recursive class definitions (since here, the two classes are not really recursive because I have removed the caseCons method in the visitor) and ocaml accepts this modified code. I tried also to instantiate the 'a type parameter with int (so I have caseNil:int and visit:visitor->int) and this is also accepted. Why is my code rejected ? What does mean the error message ? Thank you Regards Sébastien ------------------- 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