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 EAA27142; Mon, 8 Jul 2002 04:08:15 +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 EAA24559 for ; Mon, 8 Jul 2002 04:08:14 +0200 (MET DST) Received: from sunny.pacific.net.au (sunny.pacific.net.au [203.25.148.40]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g6828Cf29079 for ; Mon, 8 Jul 2002 04:08:12 +0200 (MET DST) Received: from wisma.pacific.net.au (wisma.pacific.net.au [210.23.129.72]) by sunny.pacific.net.au with ESMTP id g68287Ss026137; Mon, 8 Jul 2002 12:08:07 +1000 (EST) Received: from ozemail.com.au (ppp60.dyn18.pacific.net.au [61.8.18.60]) by wisma.pacific.net.au with ESMTP id MAA01728; Mon, 8 Jul 2002 12:08:05 +1000 (EST) Message-ID: <3D28F404.7000104@ozemail.com.au> Date: Mon, 08 Jul 2002 12:08:04 +1000 From: John Max Skaller User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2.1) Gecko/20010901 X-Accept-Language: en-us MIME-Version: 1.0 To: Brian Smith CC: OCaml Mailing list Subject: Re: [Caml-list] Polymorphic methods (longest error message ever!) References: <3D28E9F8.5020308@uiowa.edu> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Brian Smith wrote: > > # class node : node_type = object (self) > method as_variant = `Node (self :> node_type) > end;; > ^^^^ > This expression cannot be coerced to type > node_type = < as_variant : 'a. [> `Node of node_type] as 'a >; > it has type < as_variant : 'c; .. > as 'b but is here used with type 'b > > # class node : node_type = object (self) > method as_variant : 'a. [> `Node of node_type] as 'a > = `Node (self :> node_type) > end;; > The class type object method as_variant : [> `Node of node_type] end > is not matched by the class type node_type > The class type object method as_variant : [> `Node of node_type] end > is not matched by the class type > object method as_variant : [> `Node of node_type] end > The method as_variant has type 'a. [> `Node of node_type] as 'a > but is expected to have type 'b. [> `Node of node_type] as 'b > The universal variable 'b would escape its scope > > I have no idea what the error message means. Heh. I can't answer your question, but I have to fall about laughing (is there a French idiom for that?) at the idea this is a long error message. I often get error messages of 100's of lines, my console buffer isn't set to 10,000 lines without reason. Just imagine your polymophic variant type [> Node of node_type] was replace statement_t below .. and don't ignore the fact that the ctor arguments themselves are similar polymorphic variant types like expr_t ... and this isn't a large variant. ---------------------------------------------- and statement_t = [ | `AST_open of range_srcref * qualified_name_t | `AST_comment of string (* for documenting generated code *) (* definitions *) | `AST_function of range_srcref * id_t * parameter_t list * typecode_t * statement_t list | `AST_procedure of range_srcref * id_t * parameter_t list * statement_t list (* types *) | `AST_union of range_srcref * id_t * (id_t * typecode_t) list | `AST_struct of range_srcref * id_t * (id_t * typecode_t) list | `AST_type_alias of range_srcref * id_t * typecode_t (* variables *) | `AST_val_decl of range_srcref * id_t * typecode_t option * expr_t option | `AST_var_decl of range_srcref * id_t * typecode_t option * expr_t option (* module system *) | `AST_untyped_module of range_srcref * id_t * statement_t list | `AST_typed_module of range_srcref * id_t * typecode_t * statement_t list | `AST_module_binding of range_srcref * id_t * expr_t | `AST_typed_functor of range_srcref * id_t * parameter_t list * typecode_t * statement_t list | `AST_untyped_functor of range_srcref * id_t * parameter_t list * statement_t list | `AST_interface of range_srcref * id_t * statement_t list | `AST_type of range_srcref * id_t | `AST_function_decl of range_srcref * id_t * typecode_t | `AST_procedure_decl of range_srcref * id_t * typecode_t (* control structures: primitives *) | `AST_label of range_srcref * id_t (* for testing the code generator! *) | `AST_goto of range_srcref * id_t (* for testing the code generator! *) | `AST_call of range_srcref * expr_t * expr_t | `AST_read of range_srcref * id_t | `AST_return of range_srcref * expr_t | `AST_nop of range_srcref * string | `AST_block of range_srcref * statement_t list | `AST_if of range_srcref * (range_srcref * (expr_t * statement_t)) list * (range_srcref * statement_t) | `AST_while of range_srcref * expr_t * statement_t (* exceptions *) | `AST_attempt of range_srcref * (range_srcref * statement_t) * (* the attempt *) (range_srcref * statement_t list) * (* the handlers *) (range_srcref * statement_t list) (* the finally block *) | `AST_except_handler of range_srcref * id_t * parameter_t list * statement_t list | `AST_raise of range_srcref * id_t * expr_t (* binding structures [prolog] *) | `AST_abs_decl of range_srcref * id_t * c_t | `AST_const_decl of range_srcref * id_t * typecode_t * c_t | `AST_fun_decl of range_srcref * id_t * typecode_t list * typecode_t * c_t | `AST_proc_decl of range_srcref * id_t * typecode_t list * c_t | `AST_header of range_srcref * string | `AST_code of range_srcref * string | `AST_export of range_srcref * suffixed_name_t * string ] -- John Max Skaller, mailto:skaller@ozemail.com.au snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia. voice:61-2-9660-0850 ------------------- 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