Re: [Caml-list] in and out channels into memory

Skip to first unread message

Richard Jones

Jul 10, 2006, 5:52:42 AM7/10/06
to Jim Miller,
On Sun, Jul 09, 2006 at 09:53:29PM -0400, Jim Miller wrote:
> Is there a way in OCaml to read and write into memory using in and out
> channels in the standard distribution? It seems like there are functions
> for converting everything else to in and out channels but I can't seem to
> find anything for writing into and out of memory. If there isn't something
> already, is there a function for creating new in and out channels?

Not for the in/out_channel in the standard distribution.

However if you can change the code to use the IO class types defined
here ( then you
can use something like input_string from the Netstring library:

let s = "1\n2\n3\n4" in
let ch = new input_string s in
ch#input_line ()

If you can't change the code, then the best you can do might be to
read and write a temporary file (see: Filename.open_temp_file).

Another alternative from the std lib is Buffer, but that also requires
changing the code.


Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology -
Team Notepad - intranets and extranets for business -

Caml-list mailing list. Subscription management:
Beginner's list:
Bug reports:

Reply all
Reply to author
0 new messages