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 759407FEFE for ; Fri, 8 Jul 2016 12:54:38 +0200 (CEST) IronPort-PHdr: 9a23:EuD3KBKOCkXV6YeZHNmcpTZWNBhigK39O0sv0rFitYgVK/7xwZ3uMQTl6Ol3ixeRBMOAuqoC0LKd6f+ocFdDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXsq3G/pQQfBg/4fVIsYL+kQsiJ14/tiKibwN76W01wnj2zYLd/fl2djD76kY0ou7ZkMbs70RDTo3FFKKx8zGJsIk+PzV6nvp/jtLYqySlbuuog+shcSu26Ov1gFf0LOg87KHg479HHshzKTA3HpidNEzZerh0dOQ/J6xXiXpq5libit+Vn1WHOJ8r6SrQsWTnk66pzSRDyhQ8aMT8ntXrelMtxgeRVukTyiQZ4xtv7aYuPNfd6NpjWfd4ASHAJCslYXTZAD4f6dIAPAvAMJ85XqoD8ox0Fqh7oVlrkP//m1jId3iy+5qY9yel0VFyf0Q== Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=gabriel.scherer@gmail.com; spf=Pass smtp.mailfrom=gabriel.scherer@gmail.com; spf=None smtp.helo=postmaster@mail-it0-f67.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of gabriel.scherer@gmail.com) identity=pra; client-ip=209.85.214.67; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of gabriel.scherer@gmail.com designates 209.85.214.67 as permitted sender) identity=mailfrom; client-ip=209.85.214.67; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; 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@mail-it0-f67.google.com) identity=helo; client-ip=209.85.214.67; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="postmaster@mail-it0-f67.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0ClAAAfhn9Xf0PWVdFbFoN+fAanXIV7hjOGfyKFdgKBJgc8EAEBAQEBAQEBEQEBCQsLCR8xgjKCGgEBBAESEQQZARsSCwEDAQsGBQQHBQgNHQICIgERAQUBChIGExIQh3MBAw8IDqAQgTE+MYs7gWqCWgWFfQoZJwMKUoNUAQEBAQEBAQMBAQEBAQEBGAIGEIYXhE2EboJUgloBBIZSDIx8hTqBWoQyiEOCOIx0jk8SHoEPDyaELCAyiRYBAQE X-IPAS-Result: A0ClAAAfhn9Xf0PWVdFbFoN+fAanXIV7hjOGfyKFdgKBJgc8EAEBAQEBAQEBEQEBCQsLCR8xgjKCGgEBBAESEQQZARsSCwEDAQsGBQQHBQgNHQICIgERAQUBChIGExIQh3MBAw8IDqAQgTE+MYs7gWqCWgWFfQoZJwMKUoNUAQEBAQEBAQMBAQEBAQEBGAIGEIYXhE2EboJUgloBBIZSDIx8hTqBWoQyiEOCOIx0jk8SHoEPDyaELCAyiRYBAQE X-IronPort-AV: E=Sophos;i="5.28,329,1464645600"; d="scan'208,217";a="184272552" Received: from mail-it0-f67.google.com ([209.85.214.67]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 08 Jul 2016 12:54:33 +0200 Received: by mail-it0-f67.google.com with SMTP id u186so2700377ita.1 for ; Fri, 08 Jul 2016 03:54:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=qr5Lbn2K5cj9kXqXF73s6Tg266acASDgjM/4bgOWrQw=; b=C7B014TOVOP617aAqYbicrYZpHzXzP/70g5sywIwaPZoqsKiWOrTe4tWjcBXKXIjD7 2DSUHqrXNRhlQ0eghdg8kyCdMKFECucWV+g3EdTulqy7SAPJ7twj17Akzl0l4NdK5gJd ENvF3g9kinIkiJbZ/i0lu9WbwLgA6ldE/Omsf0smjlotR/+mld1sLQgS07iLd5wjlY3r hsM+QP4F6zYI49j21Fd+6MEjRkcuZg0/+UfKEHbGBnKDUneb8DsHfetmiLX5pJ5qkpQd nu4ZJiNhnkuH5j8S7BNmpDX8/4xKZ582o8YcrY1uJweQqxWVA7tToEeVSU8t4RaBJW8Q OVDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=qr5Lbn2K5cj9kXqXF73s6Tg266acASDgjM/4bgOWrQw=; b=J2UvoN+79GfDAWhS1Qblt6G8qaoM3LcHDhF7hRUGBD/Qpr8VlsBrs7IoHHn3Wv1lDJ PHpR2VVT9Tbmbob59pg5TE7tVb0E0YxJSodsIaE8NbgJcM11tvVWr/KXfXAFXj6cyQw5 QJKKCoS7kiy6GcP5kSrDqIWO8FNn51hA/mESXWICTHOI0vb5MKZrZECePm1VtIajo+IE m6JILJa5zGx7xQvixtJUyQm9M51hpcjQNHo0RDO9plWpAVUXCJOUB4wckMh7GzRmHyVf s+XrHy7C1V1u1pqUxzBSIi0tDmBWfJ62GRhf8vCmIt3dF+7rnh12zhtj6oxa62q9mt8M rM2A== X-Gm-Message-State: ALyK8tKoCeS/8SrwBShRziEEzhwDjyNl5oYPCRvUvR88Eldk5oUOvlTP6Et+wYMrmg+He7zemVhuaWjdyQLlLw== X-Received: by 10.36.141.196 with SMTP id w187mr2511093itd.87.1467975272530; Fri, 08 Jul 2016 03:54:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.79.68.130 with HTTP; Fri, 8 Jul 2016 03:53:53 -0700 (PDT) In-Reply-To: <20160708081627.GL11971@HPArchRod.localdomain> References: <20160708080134.GK11971@HPArchRod.localdomain> <20160708081627.GL11971@HPArchRod.localdomain> From: Gabriel Scherer Date: Fri, 8 Jul 2016 06:53:53 -0400 Message-ID: To: Rodolphe Lepigre Cc: Nicolas Ojeda Bar , OCaml Mailing List Content-Type: multipart/alternative; boundary=94eb2c07ab48a8a39505371da05d Subject: Re: [Caml-list] Printf.sprintf "%a" --94eb2c07ab48a8a39505371da05d Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable For non-formatted printing, I find that bprintf (using Buffer.t) is the more composable primitive. On Fri, Jul 8, 2016 at 4:16 AM, Rodolphe Lepigre < rodolphe.lepigre@univ-savoie.fr> wrote: > Thanks for your answer! > > > I don't think this is possible with Printf. But if you can switch to > Format > > you can use Format.asprintf instead. > > Yes, I know it is possible to use Format. This is actually what I am doing > currently! However, I am not using any of the formating features, so I'd > like to switch to Printf to avoid going from channels to formatters all t= he > time... > > >> Dear list, > >> > >> If I define two values > >> > >> val p : type out_channel -> blop -> unit > >> val e : blop > >> > >> then I can do something like > >> > >> Printf.printf "%a" p e > >> > >> but I can't find a way to do something like > >> > >> Printf.sprintf "%a" p e > >> > >> which is not well-typed. Is there any trick that I can use to avoid > >> changing the type of [p] to [blop -> string]? > >> > >> Cheers, > >> > >> Rodolphe > > Cheers, > > Rodolphe > -- > Rodolphe Lepigre > LAMA, Universit=C3=A9 Savoie Mont Blanc, FRANCE > http://lama.univ-smb.fr/~lepigre/ > On 08/07/2016 10:08, Nicolas Ojeda Bar wrote: > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > --94eb2c07ab48a8a39505371da05d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
For non-formatted printing, I find that bprintf (using Buf= fer.t) is the more composable primitive.

On Fri, Jul 8, 2016 at 4:16 AM, Rodolphe L= epigre <rodolphe.lepigre@univ-savoie.fr> wrote= :
Thanks for your answer!

> I don't think this is possible with Printf.=C2=A0 But if you can s= witch to Format
> you can use Format.asprintf instead.

Yes, I know it is possible to use Format. This is actually what I am= doing
currently! However, I am not using any of the formating features, so I'= d
like to switch to Printf to avoid going from channels to formatters all the=
time...

>> Dear list,
>>
>> If I define two values
>>
>> =C2=A0 val p : type out_channel -> blop -> unit
>> =C2=A0 val e : blop
>>
>> then I can do something like
>>
>> =C2=A0 Printf.printf "%a" p e
>>
>> but I can't find a way to do something like
>>
>> =C2=A0 Printf.sprintf "%a" p e
>>
>> which is not well-typed. Is there any trick that I can use to avoi= d
>> changing the type of [p] to [blop -> string]?
>>
>> Cheers,
>>
>> Rodolphe

Cheers,

Rodolphe
--
Rodolphe Lepigre
LAMA, Universit=C3=A9 Savoie Mont Blanc, FRANCE
http://lama.univ-smb.fr/~lepigre/
On 08/07/2016 10:08, Nicolas= Ojeda Bar wrote:

--
Caml-list mailing list.=C2=A0 Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocam= l_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

--94eb2c07ab48a8a39505371da05d--