From: David Allsopp <dra-news@metastack.com>
To: OCaml List <caml-list@inria.fr>
Subject: RE: [Caml-list] <DKIM> Re: Vagaries of Printf variants
Date: Wed, 29 Oct 2014 10:34:36 +0000 [thread overview]
Message-ID: <E51C5B015DBD1348A1D85763337FB6D9E966E4C3@Remus.metastack.local> (raw)
In-Reply-To: <544FFA23.9000305@laposte.net>
Pierre Chambart wrote:
> On 28/10/2014 10:19, Gabriel Scherer wrote:
> > If you know from the start that you need this flexibility, the easiest
> > way is probably to use Printf.bprintf from the start, which is
> > reasonably efficient and flexible (or write your fprintf-formats with
> > %s rather than %a).
> >
> > If you specifically need to convert code that uses (f)printf with
> > minimal changes, you have the problem that your %a/%t functions work
> > with out_channel, not strings. The simplest way out is probably to use
> > Unix.pipe (which is available on Windows) to create an out_channel
> > that you write into and read back the content as a string.
> I wouldn't recommend something like that: you are exposing yourself to
> deadlocks.
> If you are not carefull, your write will reach the OS-defined limit to the
> pipe size, and will block the process until someone reads the pipe. So you
> will need another thread to read the channel...
That's a good point, thanks. Though my use-case here is strictly for console output, where blowing the minimum 4K allocated to the pipe would be unlikely - however, it can be easily solved with a C thread (rather than the weight of an OCaml thread).
David
prev parent reply other threads:[~2014-10-29 10:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-27 17:56 [Caml-list] " David Allsopp
2014-10-27 18:51 ` Daniel Bünzli
2014-10-28 9:04 ` David Allsopp
2014-10-28 9:19 ` Gabriel Scherer
2014-10-28 9:33 ` David Allsopp
2014-10-28 20:18 ` [Caml-list] <DKIM> " Pierre Chambart
2014-10-29 10:34 ` David Allsopp [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=E51C5B015DBD1348A1D85763337FB6D9E966E4C3@Remus.metastack.local \
--to=dra-news@metastack.com \
--cc=caml-list@inria.fr \
/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