caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* in and out channels into memory
@ 2006-07-10  1:53 Jim Miller
  2006-07-10  9:48 ` [Caml-list] " Richard Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Jim Miller @ 2006-07-10  1:53 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 370 bytes --]

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?

Thanks

[-- Attachment #2: Type: text/html, Size: 397 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] in and out channels into memory
  2006-07-10  1:53 in and out channels into memory Jim Miller
@ 2006-07-10  9:48 ` Richard Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Jones @ 2006-07-10  9:48 UTC (permalink / raw)
  To: Jim Miller; +Cc: caml-list

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-07-10  9:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-10  1:53 in and out channels into memory Jim Miller
2006-07-10  9:48 ` [Caml-list] " Richard Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).