[
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: | 2006-07-10 (09:49) |
From: | Richard Jones <rich@a...> |
Subject: | Re: [Caml-list] in and out channels into memory |
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 (http://www.ocaml-programming.de/rec/IO-Classes.html) 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. Rich. -- Richard Jones, CTO Merjis Ltd. Merjis - web marketing and technology - http://merjis.com Team Notepad - intranets and extranets for business - http://team-notepad.com