caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Richard Jones <rich@annexia.org>
To: Jim Miller <gordon.j.miller@gmail.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] in and out channels into memory
Date: Mon, 10 Jul 2006 10:48:59 +0100	[thread overview]
Message-ID: <20060710094859.GA4083@furbychan.cocan.org> (raw)
In-Reply-To: <beed19130607091853p6f8553bbp5c70928d183bbe66@mail.gmail.com>

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


      reply	other threads:[~2006-07-10  9:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-10  1:53 Jim Miller
2006-07-10  9:48 ` Richard Jones [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060710094859.GA4083@furbychan.cocan.org \
    --to=rich@annexia.org \
    --cc=caml-list@yquem.inria.fr \
    --cc=gordon.j.miller@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).