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 IAA06243; Fri, 18 Jan 2002 08:37:15 +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 IAA06268 for ; Fri, 18 Jan 2002 08:37:14 +0100 (MET) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g0I7bDj00978 for ; Fri, 18 Jan 2002 08:37:13 +0100 (MET) Received: from tet.kurims.kyoto-u.ac.jp (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3/3.7W) with ESMTP id QAA21086; Fri, 18 Jan 2002 16:37:09 +0900 (JST) Received: from localhost (localhost [127.0.0.1]) by tet.kurims.kyoto-u.ac.jp (8.11.6/8.11.6) with ESMTP id g0I6efH00746; Fri, 18 Jan 2002 15:40:41 +0900 (JST) (envelope-from garrigue@kurims.kyoto-u.ac.jp) To: warplayer@free.fr Cc: caml-list@inria.fr Subject: Re: [Caml-list] Type hidding In-Reply-To: <01ca01c19f7e$a566fbd0$ac00a8c0@warp> References: <000901c19ecf$b8c93ee0$0b01a8c0@mit.edu> <01ca01c19f7e$a566fbd0$ac00a8c0@warp> X-Mailer: Mew version 1.94.2 on Emacs 20.7 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20020117224041Z.garrigue@kurims.kyoto-u.ac.jp> Date: Thu, 17 Jan 2002 22:40:41 -0800 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: "Warp" > Ok I've tried this doing : > > (set_window_data wnd#hwnd 10); > let v = (get_window_data wnd#hwnd) in > (print_int (Obj.magic v: int)); > > But it print a wrong number ( not 10 ) > I've tried to trace calls into the C DLL where primitives *_window_data are, > I can see the set_window_data call but the get_window_data call is NOT done > by the interpreter Aaargh! No, never use Obj.magic. And please, never suggest to use it to resolve a type error. Its only use is in relation to external C code, when you exactly know what is happening! Here the problem is that the type of v ends up being "wnd:hwnd -> 'a" rather than "'a" as you expected. Since you omitted the label on the argument, and the result type could be unified with anything, the compiler believed that you were attempting to pass another argument... By using magic, you are printing the address of a closure as an integer. Basic rules: * a function should never return 'a if it does not also appear in a contravariant position (that is, as argument) * it is better not to put labels on functions of only one argument, particularly when their return type is polymorphic (to avoid the above confusion) The right response to your problem was already in other messages. Cheers, Jacques Garrigue ------------------- 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