Hi,

The main reason is that marshaling is a part of standard library, i.e., the stdlib.cma, where Unix.file_descr is a part of the unix library, and the Unix library is not included into the Standard library, thus the latter cannot depend on the former. So, the only way to introduce such functionality would be to add Unix.dump_value : file_descr -> 'a -> unit`, i.e., to the Unix module. It is doable, and I saw such function in third-party libraries and implemented it myself. There is a small issue with the buffering, as all file_descr operations are unbuffered and it is assumed that the do not create any intermediate storages. But the only way to implement the dump_value function is to use an intermediate buffer, that kind of contradicts the general spirit of the file_descr interface. 

Regards,
Ivan Gotovchits

On Tue, Jun 13, 2017 at 11:01 AM, Francois BERENGER <berenger@bioreg.kyushu-u.ac.jp> wrote:
Hello,

Sorry for the maybe stupid question.

I mean fd has type Unix.file_descr.

I am just wondering why marshaling has to always go through an in or out_channel.

Is it just so that there is not dependency between the Marshal and the Unix module?

I am worried about the data copying that might happen because
of the channel interposed between me and my file.

Regards,
F.

--
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs