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 CAA03475; Tue, 25 Mar 2003 02:15:44 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA24791 for ; Tue, 25 Mar 2003 02:15:42 +0100 (MET) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h2P1FeX17471 for ; Tue, 25 Mar 2003 02:15:41 +0100 (MET) 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 KAA17163; Tue, 25 Mar 2003 10:15:33 +0900 (JST) To: sebastien.briais@epfl.ch Cc: caml-list@inria.fr Subject: Re: [Caml-list] About polymorphic methods and recursive classes In-Reply-To: <3E7F457A.80006@epfl.ch> References: <3E7C4784.6000901@epfl.ch> <20030324094415.6679de19.Damien.Pous@ens-lyon.fr> <3E7F457A.80006@epfl.ch> 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: <20030325101545S.garrigue@kurims.kyoto-u.ac.jp> Date: Tue, 25 Mar 2003 10:15:45 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) X-Spam: no; 0.00; jacques:01 caml-list:01 inferred:01 recursion:01 bug:01 compiler:01 ocaml:01 int:01 garrigue:01 polymorphic:01 classes:03 interpreter:03 recursive:03 object:03 types:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Sebastien Briais > >># 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 > > I am still puzzled by the answer of the interpreter which says me that > "v has type 'a visitor; It has no method caseNil" > although it has inferred just before that > "class virtual ['a] visitor : object method virtual caseNil : 'a end" > > Moreover, it seems odd to me that it works with class types but not without. > These class types should be inferred by Ocaml, shouldn't they ? (and > they seems > to be correctly inferred in my example (in the first part of it)) Actually no. Polymorphic methods are not inferred, but declared. And polymorphic type variables should not be used as parameters to simultaneously defined types. Actually, your mutually recursive definition should not be accepted to begin with. It clearly results in a wrong internal type. The problem is not virtual class vs. class types. The virtual class version will work if you drop the recursion (replace "and" by "class"). > So I ask again : how should I interpret the error message given by ocaml ? As a bug in the compiler. The error should be reported earlier. 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