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 QAA13985; Mon, 21 Jun 2004 16:26:40 +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 QAA13958 for ; Mon, 21 Jun 2004 16:26:39 +0200 (MET DST) Received: from postfix4-2.free.fr (postfix4-2.free.fr [213.228.0.176]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i5LEQcSH021337 for ; Mon, 21 Jun 2004 16:26:38 +0200 Received: from warp (lns-th2-5f-81-56-197-80.adsl.proxad.net [81.56.197.80]) by postfix4-2.free.fr (Postfix) with SMTP id 02E5219485F; Mon, 21 Jun 2004 16:26:38 +0200 (CEST) Message-ID: <000701c4579b$a508eef0$ef01a8c0@warp> From: "Nicolas Cannasse" To: "Henri DF" , References: Subject: Re: [Caml-list] odd typing behavior Date: Mon, 21 Jun 2004 16:25:46 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 X-Miltered: at concorde with ID 40D6F01E.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; cannasse:01 warplayer:01 caml-list:01 infer:01 hashtbl:01 hashtbl:01 val:01 abstr:01 cannasse:01 compiler:01 nicolas:01 nicolas:01 int:01 int:01 readable:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Here is a boiled-down example of a problem that i can't figure out. > Can anyone explain this ? > > thanks > henri That's a normal behavior : the compiler can't infer correctly the monorphic type of the Hashtbl if this type have been declared after the instance is created. (that's version 1 against 3). For version 2 , you're only defining a type alias, not a new type, so there is no problem with that. Objects here are not an issue, you can get the same behavior without them, but looks like in this case the (more readable) error message is lost : # let h = Hashtbl.create 0;; val h : ('_a, '_b) Hashtbl.t = # type t = { x : int };; type t = { x : int; } # Hashtbl.add h 3 { x = 5 };; Characters 16-25: Hashtbl.add h 3 { x = 5 };; ^^^^^^^^^ This expression has type t but is here used with type 'a The type constructor t would escape its scope Regards, Nicolas Cannasse ------------------- 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