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 OAA27250; Tue, 9 Jul 2002 14:20:46 +0200 (MET DST) 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 OAA26955 for ; Tue, 9 Jul 2002 14:20:45 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from p5080F1F0.dip.t-dialin.net (p5080F1F0.dip.t-dialin.net [80.128.241.240]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g69CKgH10436 for ; Tue, 9 Jul 2002 14:20:44 +0200 (MET DST) Received: from hera.ffm.npc.de (hera.ffm.npc.de [192.168.130.8]) by p5080F1F0.dip.t-dialin.net (Postfix STYX NPC GmbH) with ESMTP id 91B9778E0; Tue, 9 Jul 2002 14:20:36 +0200 (CEST) Received: from gerd-stolpmann.de (ares.ffm.npc.de [192.168.130.32]) by hera.ffm.npc.de (Postfix HERA NPC GmbH) with ESMTP id A6E805683; Tue, 9 Jul 2002 14:20:35 +0200 (CEST) Message-ID: <3D2AD513.1010500@gerd-stolpmann.de> Date: Tue, 09 Jul 2002 14:20:35 +0200 From: Gerd Stolpmann User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529 X-Accept-Language: en-us, en MIME-Version: 1.0 To: gaurav_chanda@lycos.com Cc: caml-list@pauillac.inria.fr Subject: Re: [Caml-list] Pxp objects inside class definition References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Gaurav Chanda wrote: > Hello > > I am using the Polymorphic XML Parser (PXP) to parse XML documents. I have made 2 files : point.ml and point.mli, which contain simple class definitions. > > The file point.mli contains: > > open Pxp_yacc ; > open Pxp_document ; > open Pxp_types ; > > class type point_sig = > object > value mutable x : Pxp_document.node 'a; > end; > > class point : point_sig ; > > > The file point.ml contains: > > open Pxp_yacc ; > open Pxp_document ; > open Pxp_types ; > > class type point_sig = > object > value mutable x : Pxp_document.node 'a; > end ; > > value def = "" ; > value def = parse_wfdocument_entity default_config (from_string def) default_spec ; > value defr = def#root ; > > class point:point_sig = > object > value mutable x = defr; > end; > > I get an error message while compilation. My compilation command is : > ocamlopt -pp "camlp4r pa_extend.cmo" -I +camlp4 -I Ty/ -I /usr/lib/ocaml/site-lib/netstring -I /usr/lib/ocaml/site-lib/pxp-engine -I /usr/lib/ocaml/site-lib/pxp-lex-iso88591/ -c point.mli point.ml > > > The error message is : > > File "point.ml", line 15, characters 8-67: > The class type > object > val mutable x : > ('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.node > end > is not matched by the class type point_sig > The class type > object > val mutable x : > ('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.node > end > is not matched by the class type > object > val mutable x : > ('a Pxp_document.node #Pxp_document.extension as 'a) Pxp_document.node > end [...] > > I am not being able to define PXP objects inside classes. Could you help me solve this problem ? Hi Garuav, (the following in classic syntax) the problem is that 'a Pxp_document.node is not the full type, because there is a constraint on the parameter of the class Pxp_document.node, and the compiler correctly augments the type such that it reads ('a Pxp_document.node #Pxp_document.extension as 'a) Pxp_document.node. However, defr has the type ('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.node, which is not the same. This is all the long error message wants to tell you. The solution is quite simple: Use the complete type instead of 'a Pxp_document.node, i.e. class type point_sig = object val mutable x : ('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.node end Sorry that the types of PXP are that complicated. ('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.node reflects the fact that nodes have extensions, and the extensions are recursively bound to their nodes. This is sometimes a bit unhandy. Gerd -- ------------------------------------------------------------ Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de ------------------------------------------------------------ ------------------- 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