Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2002-06-11 (15:45)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] Unix.file_descr -> int ???
> Suddently, I'm unable to recover file descriptor from Unix's
> file_descr. At least, Unix module does not contain any
> function doing that and the type is abstract.
> What was a reason for the limitaion?

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.

> Is there some way (apart from hacking ocaml) to do that?

Within well-typed code, no.  With typing hacks, yes.  But what would
you want to do this?

- Xavier Leroy
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: