From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr 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 4D1C17EE99 for ; Tue, 7 Jan 2014 22:02:12 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of steph@glondu.net) identity=pra; client-ip=138.231.136.39; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="steph@glondu.net"; x-sender="steph@glondu.net"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of steph@glondu.net) identity=mailfrom; client-ip=138.231.136.39; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="steph@glondu.net"; x-sender="steph@glondu.net"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of postmaster@redisdead.crans.org designates 138.231.136.39 as permitted sender) identity=helo; client-ip=138.231.136.39; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="steph@glondu.net"; x-sender="postmaster@redisdead.crans.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlQBAN5qzFKK54gnl2dsb2JhbABZhxazY4MJgRUWDgEBAQEBCBYHPIImAQEEI1URCxoCBRYLAgIJAwIBAgFFEwgCiAAEqXWaKReBKY1iFoJZgUgBA5gXhkWEBop4 X-IPAS-Result: AlQBAN5qzFKK54gnl2dsb2JhbABZhxazY4MJgRUWDgEBAQEBCBYHPIImAQEEI1URCxoCBRYLAgIJAwIBAgFFEwgCiAAEqXWaKReBKY1iFoJZgUgBA5gXhkWEBop4 X-IronPort-AV: E=Sophos;i="4.95,620,1384297200"; d="scan'208";a="43896270" Received: from redisdead.crans.org ([138.231.136.39]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 07 Jan 2014 22:02:11 +0100 Received: from [10.125.1.2] (fbx.up7.fr [81.56.96.177]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by redisdead.crans.org (Postfix) with ESMTPSA id 16D2C2364 for ; Tue, 7 Jan 2014 22:02:10 +0100 (CET) Message-ID: <52CC6B52.3000808@glondu.net> Date: Tue, 07 Jan 2014 22:02:10 +0100 From: =?UTF-8?B?U3TDqXBoYW5lIEdsb25kdQ==?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131103 Icedove/17.0.10 MIME-Version: 1.0 To: caml-list@inria.fr References: In-Reply-To: X-Enigmail-Version: 1.6 OpenPGP: id=49881AD3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] wrapping a string in an in_channel Le 05/01/2014 09:23, Martin DeMello a =C3=A9crit : > Does OCaml have any equivalent to ruby's StringIO, to wrap an > in_channel around a string and then treat it as if it were a file? Technically, it should be possible by using low-level Unix machinery like in the following: let wrap_string s =3D let infd, outfd =3D Unix.pipe () in let inc =3D Unix.in_channel_of_descr infd in let outc =3D Unix.out_channel_of_descr outfd in let writer () =3D output_string outc s; flush outc; close_out outc in Thread.create writer (); inc ... but the other suggestions are probably better... Cheers, --=20 St=C3=A9phane