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 JAA19590; Thu, 31 Jan 2002 09:52:47 +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 JAA18457 for ; Thu, 31 Jan 2002 09:52:46 +0100 (MET) Received: from ebene.inrialpes.fr (ebene.inrialpes.fr [194.199.18.70]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g0V8qkD01809 for ; Thu, 31 Jan 2002 09:52:46 +0100 (MET) Received: from pop-serv.inrialpes.fr (pop-serv.inrialpes.fr [194.199.18.66]) by ebene.inrialpes.fr (8.11.6/8.11.6) with ESMTP id g0V8qVJ09269 for ; Thu, 31 Jan 2002 09:52:31 +0100 (MET) Received: from inrialpes.fr (cime.inrialpes.fr [194.199.23.76]) by pop-serv.inrialpes.fr (8.10.2+Sun/8.11.3/ImagV2) with ESMTP id g0V8qWK15422 for ; Thu, 31 Jan 2002 09:52:32 +0100 (MET) Message-ID: <3C5905CF.A09E2519@inrialpes.fr> Date: Thu, 31 Jan 2002 09:52:31 +0100 From: Frederic Tronel X-Mailer: Mozilla 4.76 [en] (X11; U; SunOS 5.8 sun4u) X-Accept-Language: en MIME-Version: 1.0 To: caml-list@inria.fr Subject: [Caml-list] Parametric classes and weak types Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello, I'm facing the following problems. I've written a parser using ocamlyacc, it generates a object of a given class, that in turn itself contains many fields of different classes and so on ... It can be considered as being an abstract syntax tree, except that each node of the tree has not a unique type. Up to this point everything works perfectly. Then I want to generate a new tree which consists of a totally different set of classes (although semantically related). But I want this mechanism to be as generic as possible (that is, I don't want the first set of classes to be bound to the second set of classes). To do this, I've used parametric classes (for the first set of classes) in combination with weak types. But I'm facing real problems either at runtime, or even at compile time. It seems that either the interpreter or the compiler is unable to synthesize the types of my data structures, being locked during either the interpretation of an expression, or the compilation of a .ml. I've tried to generate a small example that seems to generate problems with the interpreter, since the original code is much too long to be posted: exception E class ['a] ca = object (this) val mutable into = ([] : 'a list) method get_into = match into with [] -> raise E |[x] -> x |_ -> raise E method set_into x = into <- [x] method set_transform = this#set_into method transform = this#get_into this end and ['a,'b] cb = object (this) val mutable into = ([] : 'a list) method get_into = match into with [] -> raise E |[x] -> x |_ -> raise E method set_into x = into <- [x] val mutable atts = ([] : 'b ca list) method get_atts = atts method set_atts x = atts <- x method set_transform a b = this#set_into a ; List.iter (fun x -> x#set_transform b) atts method transform = let cb = this#get_into this in let ca = List.fold_left ( fun a b -> [b#transform]@a ) [] atts in (cb,ca) end Using ocaml 3.04 under solaris or linux, using the ocaml I have the following problem: # let ca1 = new ca ;; val ca1 : ('a -> '_b) ca as 'a = # let cb1 = new cb ;; val cb1 : ('a -> '_b, 'c ca -> '_d as 'c) cb as 'a = # cb1#set_atts [ca1];; - : unit = () # cb1#set_transform (fun x -> x) (fun x -> x);; - : unit = () # cb1#transform ;; - : (('a -> 'a, ('b ca as 'c) -> 'c as 'b) cb as 'a) * 'c list = , [] # cb1#transform ;; Here it hangs indefinitely. Any idea ?? Frederic Tronel. ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr