From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 64A8E7EFCD for ; Tue, 28 Oct 2014 21:19:07 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of pierre.chambart@laposte.net) identity=pra; client-ip=193.253.67.233; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="pierre.chambart@laposte.net"; x-sender="pierre.chambart@laposte.net"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of pierre.chambart@laposte.net designates 193.253.67.233 as permitted sender) identity=mailfrom; client-ip=193.253.67.233; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="pierre.chambart@laposte.net"; x-sender="pierre.chambart@laposte.net"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@smtpout.laposte.net) identity=helo; client-ip=193.253.67.233; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="pierre.chambart@laposte.net"; x-sender="postmaster@smtpout.laposte.net"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlcBAAj6T1TB/UPpm2dsb2JhbABch0DPbIMgAoE3AQEBAQERAQEBAQEGCwsJFC6EAwEBBCNVARALGAICBRYLAgIJAwIBAgFFBgEMAQcCiCcBGbIqjXoQhn8BAQEBAQEEAQEBAQEBHIEsjwZXB4J3gVQFkxOMBoY9O4oMh3qBcoFEAQEB X-IPAS-Result: AlcBAAj6T1TB/UPpm2dsb2JhbABch0DPbIMgAoE3AQEBAQERAQEBAQEGCwsJFC6EAwEBBCNVARALGAICBRYLAgIJAwIBAgFFBgEMAQcCiCcBGbIqjXoQhn8BAQEBAQEEAQEBAQEBHIEsjwZXB4J3gVQFkxOMBoY9O4oMh3qBcoFEAQEB X-IronPort-AV: E=Sophos;i="5.04,804,1406584800"; d="scan'208";a="85123042" Received: from smtpout8.laposte.net (HELO smtpout.laposte.net) ([193.253.67.233]) by mail3-smtp-sop.national.inria.fr with ESMTP; 28 Oct 2014 21:18:45 +0100 Received: from [192.168.0.132] ([81.64.137.19]) by mwinf8515-out with ME id 8kJj1p0030RHR0103kJjbG; Tue, 28 Oct 2014 21:18:45 +0100 Message-ID: <544FFA23.9000305@laposte.net> Date: Tue, 28 Oct 2014 21:18:43 +0100 From: Pierre Chambart User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.1.2 MIME-Version: 1.0 To: Gabriel Scherer , David Allsopp CC: OCaml List References: <000001cff20f$57052560$050f7020$@metastack.com> <8D9D2D7B6A29486D80BB692EC24DBE06@erratique.ch> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] Re: Vagaries of Printf variants 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... -- Pierre