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 NAA00747; Wed, 12 Jun 2002 13:04:19 +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 NAA00750 for ; Wed, 12 Jun 2002 13:04:18 +0200 (MET DST) 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 g5CB47b25537; Wed, 12 Jun 2002 13:04:08 +0200 (MET DST) Received: from localhost (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 UAA22003; Wed, 12 Jun 2002 20:04:02 +0900 (JST) To: damien.doligez@inria.fr Cc: caml-list@inria.fr Subject: Re: [Caml-list] Unix.file_descr -> int ??? In-Reply-To: <20020612185729P.garrigue@kurims.kyoto-u.ac.jp> References: <200206120953.LAA0000032113@beaune.inria.fr> <20020612185729P.garrigue@kurims.kyoto-u.ac.jp> 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: <20020612200402C.garrigue@kurims.kyoto-u.ac.jp> Date: Wed, 12 Jun 2002 20:04:02 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Jacques Garrigue > From: Damien Doligez > > >Windows version: > > > > > >let dump_handle (h : Unix.file_descr) = > > > let obj = Obj.repr h in > > > if Obj.is_block obj && Obj.tag obj = Obj.custom_tag then > > > Nativeint.format "%x" (Obj.obj obj) > > > else invalid_arg "dump_handle" > > > > This does not work. You are printing the address of the custom block > > that contains the handle, but this address can change during program > > execution. > > Indeed, this is buggy. But you could have given the right answer :-) What are you making me write! This code was correct. I have been using it for months in ocamlbrowser for windows. nativeint itself is a boxed custom datatype, so outputing it will correctly output the handle, not the pointer to it. I'm just using the fact they share the same representation. Actually file_descr has another field, but we don't need it. Jacques Garrigue ------------------- 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