From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA01871 for caml-redistribution; Mon, 25 Oct 1999 20:55:22 +0200 (MET DST) 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 RAA32399 for ; Mon, 25 Oct 1999 17:08:03 +0200 (MET DST) Received: from isis.lip6.fr (isis.lip6.fr [132.227.60.2]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id RAA15026 for ; Mon, 25 Oct 1999 17:08:02 +0200 (MET DST) Received: from spi.lip6.fr (monbazillac.lip6.fr [132.227.82.65]) by isis.lip6.fr (8.8.8/jtpda-5.2.9.1+lip6) with ESMTP id RAA28039 for ; Mon, 25 Oct 1999 17:08:01 +0200 (MET DST) Received: from samael.lip6.fr (baro@samael.ufr-info-p6.jussieu.fr [132.227.89.21]) by spi.lip6.fr (8.8.6/jtpda-5.2) with ESMTP id RAA01969 for ; Mon, 25 Oct 1999 17:07:57 +0200 (MET DST) Received: from localhost (baro@localhost) by samael.lip6.fr (8.8.7/jtpda-5.2) with ESMTP id RAA10627 for ; Mon, 25 Oct 1999 17:07:58 +0200 Date: Mon, 25 Oct 1999 17:07:58 +0200 (CEST) From: Sylvain To: caml-list@inria.fr Subject: Typing question Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: weis Hello, I tried to compile this file "foobar.ml" issuing ocamlc -c -i foobar.ml > foobar.mli ocamlc -c -i foobar.mli ocamlc -c foobar.ml But at the third stage of the process, it answers me that the implementation doesn't match the interface ... I joined the file "as is" in the following, because it is a short one. -- begin -- (* Name server *) open Hashtbl exception EmptyContextAllocation exception NameAlreadyUsed of string class virtual answerToIsNewName = object method virtual isNewName : string -> bool end type nameType = ConstrName | TypeName | PredName | VarName | MuName type nameInfo = { kind : nameType ; num : int} (* one table because each number identificator is unique *) let (numTable : (int,string) t) = create 111 let global_name_cpt = ref 0 let gen_new_global () = incr global_name_cpt ; !global_name_cpt (* one nameTable should be created for each scope *) class nameTable (fatherContext : #answerToIsNewName) = object(self) val table = (create 17 : (string,nameInfo) t) val fatherContext = ((fatherContext) : #answerToIsNewName) method newName kindOf = ((let newnum = gen_new_global () in let newname = string_of_int newnum (* Temporaire *) in let register () = add numTable newnum newname ; add table newname {kind = kindOf ; num = newnum} in try find table newname ; self#newName kindOf with Not_found -> (register () ; newname)) : string) method isNewName n = try find table n ; false with Not_found -> fatherContext#isNewName n method addName name kindOf = let newnum = gen_new_global () in let register () = add numTable newnum name ; add table name {kind = kindOf ; num = newnum} in try find table name ; raise (NameAlreadyUsed name) with Not_found -> register () method delName name = remove table name end class emptyContextClass = object method newName (x : nameType) = ((raise EmptyContextAllocation) : string) method isNewName (s : string) = true method addName (n:string) (k:nameType) = ((raise EmptyContextAllocation) : unit) end let emptyContext = new emptyContextClass -- end -- Thank you. -- Sylvain Baro Sylvain.Baro@lip6.fr