Browse thread
Re: [Caml-list] Unix.file_descr -> int ???
-
Damien Doligez
-
Jacques Garrigue
- Jacques Garrigue
-
Jacques Garrigue
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2002-06-12 (11:04) |
From: | Jacques Garrigue <garrigue@k...> |
Subject: | Re: [Caml-list] Unix.file_descr -> int ??? |
From: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp> > From: Damien Doligez <damien.doligez@inria.fr> > > >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