Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Unix.file_descr -> int ???
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Max Kirillov <max630@m...>
Subject: Re: [Caml-list] Unix.file_descr -> int ???
Hello.

I was trying to trace a code with some significant amount of
select'ed fds. At some point, I faced the fact that I just
have no way to "show" a descriptor value. That was a real
shock. At the moment, the bug is found and fixed
deductively, but the question remains.

I know almost nothing about win32, but I was very surprised
to discover that win32 has functions, isomorphic to
low-level unix calls. However, I suspect (I don't have win32
headers to look in just now) that HANDLE is again a
"typedef" of intteger.

The abstraction is good for a higher-level portable api,
which would use posix or win32 functions in background,
depending on platform. I thought it to be a function
"open_connection" and so on. Now I'm happy to see that usual
"unix" functions would work well in win32.

Anyway, any meaningful type barrier is good. Maybe the
discussed too. But, since we all know that file_descr and
dir_handle are integers, could it be worthwhile to have
functions *_of_int and int_of_*?

Max.

On Tue, Jun 11, 2002 at 05:45:27PM +0200, Xavier Leroy wrote:
<...>
> Well, because file descriptors are an abstract data type.  
> What makes you think that they are integers?  None of the integer
> operations make any sense on file descriptors, e.g. adding or
> multiplying two file descriptors.
> 
> It is true that under Unix, file descriptors happen to be implemented
> as integers, but that's purely accidental.  E.g. under Windows,
> Unix.file_descr is not implemented by integers.
<...>
> - Xavier Leroy
> -------------------
-------------------
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