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 UAA13501; Thu, 20 Feb 2003 20:54:29 +0100 (MET) 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 UAA13502 for ; Thu, 20 Feb 2003 20:54:28 +0100 (MET) Received: from mallaury.noc.nerim.net (smtp-102.noc.nerim.net [62.4.17.102]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h1KJsST24749 for ; Thu, 20 Feb 2003 20:54:28 +0100 (MET) Received: from hector.lesours (lesours.starynkevitch.net [80.65.224.217]) by mallaury.noc.nerim.net (Postfix) with ESMTP id 8BC8962D04 for ; Thu, 20 Feb 2003 20:54:25 +0100 (CET) Received: from basile by hector.lesours with local (Exim 3.36 #1 (Debian)) id 18lwm3-00088O-00 for ; Thu, 20 Feb 2003 20:54:27 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <15957.12915.525441.981424@hector.lesours> Date: Thu, 20 Feb 2003 20:54:27 +0100 To: caml-list@pauillac.inria.fr Subject: [Caml-list] Error: Type variables, that can not be generalized?! In-Reply-To: <20030220195004.GA1030@first.in-berlin.de> References: <20030220195004.GA1030@first.in-berlin.de> X-Mailer: VM 7.08 under Emacs 21.2.2 From: Basile STARYNKEVITCH Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk >>>>> "Oliver" == Oliver Bandel writes: Oliver> Hello, I'm teseting my code in the toplevel, and see no Oliver> problems. I use the ocamlc-compiler and it produces this Oliver> message: Oliver> "The type of this expression, ('_a, `_b) Hashtbl.t, Oliver> contains type variables that cannot be generalized" The type ('_a, `_b) Hashtbl.t means: there exist a type '_a, there exist a type '_b, such that the displayed type is hashtable of key '_a and value '_b The type ('a,'b) Hashtbl.t means: for any type 'a and any type 'b, the displayed type is an hashtable of key 'a & value 'b Oliver> The line, where the problem occured was an unused Oliver> Hashtable-Creation. Oliver> The line was: let entry_hash = Hashtbl.create 100000 Oliver> The added line, which lets the error-message disappears Oliver> was: Oliver> Hashtbl.add entry_hash "foo" "bar" Oliver> Any hints, ewhat the problem is? The compiled unit needs to know the type of its hashtable (I don't know why). An alternative was to code: let entry_hash = ((Hashtbl.create 100000) : ((string,string) Hashtbl.t) this means that you explicitly cast the type. The compiler then infers other type taking into acount your explicit type. In practice I find useful to explicitly cast like above the type of every hashtable I create. -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basilestarynkevitchnet alias: basiletunesorg 8, rue de la Faïencerie, 92340 Bourg La Reine, France ------------------- 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