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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 7B2A17FA83 for ; Sun, 9 Apr 2017 09:46:00 +0200 (CEST) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=nicolas.ojeda.bar@lexifi.com; spf=None smtp.mailfrom=nicolas.ojeda.bar@lexifi.com; spf=None smtp.helo=postmaster@vrout30.yaziba.net Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of nicolas.ojeda.bar@lexifi.com) identity=pra; client-ip=185.56.204.35; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="nicolas.ojeda.bar@lexifi.com"; x-sender="nicolas.ojeda.bar@lexifi.com"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of nicolas.ojeda.bar@lexifi.com) identity=mailfrom; client-ip=185.56.204.35; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="nicolas.ojeda.bar@lexifi.com"; x-sender="nicolas.ojeda.bar@lexifi.com"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@vrout30.yaziba.net) identity=helo; client-ip=185.56.204.35; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="nicolas.ojeda.bar@lexifi.com"; x-sender="postmaster@vrout30.yaziba.net"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3Aktq4kh190uQvtZzssmDT+DRfVm0co7zxezQtwd8Z?= =?us-ascii?q?sesWKvvxwZ3uMQTl6Ol3ixeRBMOAuq4C07KempujcFRI2YyGvnEGfc4EfD4+ou?= =?us-ascii?q?JSoTYdBtWYA1bwNv/gYn9yNs1DUFh44yPzahANS47xaFLIv3K98yMZFAnhOgpp?= =?us-ascii?q?POT1HZPZg9iq2+yo9ZDeZwpFiCChbb9uMR67sRjfus4KjIV4N60/0AHJonxGe+?= =?us-ascii?q?RXwWNnO1eelAvi68mz4ZBu7T1et+ou+MBcX6r6eb84TaFDAzQ9L281/szrugLd?= =?us-ascii?q?QgaJ+3ART38ZkhtMAwjC8RH6QpL8uTb0u+ZhxCWXO9D9QKsqUjq+8ahkVB7oiD?= =?us-ascii?q?8GNzEn9mHXltdwh79frB64uhBz35LYbISTOfV5Y63dYMgaRXJfUclNSyxPDIS8?= =?us-ascii?q?b44VAOoAO+ZTso3xqlQKoBe7AwSnGeHhxSJShnLu36I63eQvHw/F0gI9AdwBrG?= =?us-ascii?q?/Zo8/pOKoIS+250LXEwDfFYvhL2Tn98o/IchU5rP+UXLJ/bc3RyU0tEAPellqe?= =?us-ascii?q?sI7lMC2I2esXq2eW8u9nVfiygGMgrQFxoySgxsAoiobTnYIZ0FfE9Sdnz4koP9?= =?us-ascii?q?K0UlV0bsS+EJZLsyGVKYR3QsIsQ2Fpoio11roGuZuicSUM1Z8pyRnfa/mdfIiJ?= =?us-ascii?q?5BLuTOGRLitii3JgfLKznRGy8VKvyuHkV8m01kxKritfndXWuHANzQTf6seGSv?= =?us-ascii?q?th/kehxC2A2xrP5eFDJEA4jaraJIQhwr43kZofq1jMHijzmEjwkaSYdV0k9/C1?= =?us-ascii?q?5+nkYrjqvJ+ROo5uhg3gLqgjldazDOo4PwQWQWSX5eCx2Kfg8ED5WrlGkOM6nr?= =?us-ascii?q?XDvJzHJ8kWoqi0CBJP3Ik58RawFTKm3cwYnXYZKFJFfwqKj5bzO1HJPfD4Efmy?= =?us-ascii?q?j0i2nDZr3f/HP7zhDY7XIXTZlrfuY6p951ZdyAo1099f+4pZBqwCLf/zQEP8tN?= =?us-ascii?q?3VAgUnPwCozOvrEttw24MGVWKKGKCZMafSsVGS5uIoJumBfIkVuDfhJPgi4/7h?= =?us-ascii?q?l2Q5lUUafamrw5QYdWq3Eu59LEqDe3rhmdMBHnkFvwo/QuzqiUeOXiJUZ3a3R6?= =?us-ascii?q?48/C00CJq6DYffQYCgmKCO0z2+Hp1Sf2xGDlGMEWz0d4ifQPcNaCeSItd7nTAe?= =?us-ascii?q?VLihTZUh1RC0uwPgxbpnNPLY+igftZ3+ytd4//bTlRQu9TxsCMSdzn2NHClImT?= =?us-ascii?q?YtTiM73uhcpld8yR/XjPcm3/cAT41ZuaMZWV4xbZKGk+UgBoGtUQ6eIIuHYFmj?= =?us-ascii?q?S9SiRzo2S4Ri7cUJZhNbGt6lipnY6A2oDrMcoJYHHtRg9KPX2Hz4PIB6yXvK3e?= =?us-ascii?q?8rhkMORsZfNGOnwKV48l6AVMbyj0yFmvPyJuwn1ynX+TLGkDOD?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0BXAABx5ulYhyPMOLlcGgEBAQECAQEBA?= =?us-ascii?q?QgBAQEBFQEBAQECAQEBAQgBAQEBhAmBCweOZZBNEIIqhWCPTCyFeAKDV0oUAQE?= =?us-ascii?q?BAQEBAQEBAQESAQEBCgsJCCgvgjMigkABAQEBAgEjSwsFCwsLDQ0dAgIhARIBB?= =?us-ascii?q?QEKEgYTEollAw0IBAEJnFo/jASCJocjAwqDLQEBAQEBAQQBAQEBAQEBIYtAglG?= =?us-ascii?q?FC4JfAQSHSQyOS4YgO4cAhxyEPYJUjm2LAIc4FB+BEwIPJ4EmW1YYBoQEORAMg?= =?us-ascii?q?WVziUMBAQE?= X-IPAS-Result: =?us-ascii?q?A0BXAABx5ulYhyPMOLlcGgEBAQECAQEBAQgBAQEBFQEBAQE?= =?us-ascii?q?CAQEBAQgBAQEBhAmBCweOZZBNEIIqhWCPTCyFeAKDV0oUAQEBAQEBAQEBAQESA?= =?us-ascii?q?QEBCgsJCCgvgjMigkABAQEBAgEjSwsFCwsLDQ0dAgIhARIBBQEKEgYTEollAw0?= =?us-ascii?q?IBAEJnFo/jASCJocjAwqDLQEBAQEBAQQBAQEBAQEBIYtAglGFC4JfAQSHSQyOS?= =?us-ascii?q?4YgO4cAhxyEPYJUjm2LAIc4FB+BEwIPJ4EmW1YYBoQEORAMgWVziUMBAQE?= X-IronPort-AV: E=Sophos;i="5.37,176,1488841200"; d="scan'208,217";a="268352700" Received: from vrout30-bl.yaziba.net (HELO vrout30.yaziba.net) ([185.56.204.35]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 09 Apr 2017 09:45:28 +0200 Received: from mtaout20.int.yaziba.net (mtaout20.int.yaziba.net [10.4.20.37]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by vrout30.yaziba.net (mx10.yaziba.net) with ESMTPS id 59B6D51E91 for ; Sun, 9 Apr 2017 09:45:28 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mtaout20.int.yaziba.net (Postfix) with ESMTP id 56BA0160213 for ; Sun, 9 Apr 2017 09:45:28 +0200 (CEST) X-Virus-Scanned: amavisd-new at mtaout20.int.yaziba.net Received: from mtaout20.int.yaziba.net ([127.0.0.1]) by localhost (mtaout20.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 2C6HGAmLWfOs for ; Sun, 9 Apr 2017 09:45:28 +0200 (CEST) Received: from mail-qk0-f179.google.com (mail-qk0-f179.google.com [209.85.220.179]) by mtaout20.int.yaziba.net (Postfix) with ESMTPSA id 10679160161 for ; Sun, 9 Apr 2017 09:45:28 +0200 (CEST) Received: by mail-qk0-f179.google.com with SMTP id p68so64092922qke.1 for ; Sun, 09 Apr 2017 00:45:28 -0700 (PDT) X-Gm-Message-State: AFeK/H3wmD46Ac3vV71DJ7FOjC4XFrlR/W/tQGcAbW7edxGMlYjEsNIDJ39JwC3lIqLoyTcVOvvdQQRemTl3Dg== X-Received: by 10.55.19.104 with SMTP id d101mr22118208qkh.220.1491723926810; Sun, 09 Apr 2017 00:45:26 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.49.66 with HTTP; Sun, 9 Apr 2017 00:45:06 -0700 (PDT) In-Reply-To: References: <925865e7-4237-0bcb-b4bf-76ca7d5e183e@gmail.com> From: =?UTF-8?Q?Nicol=C3=A1s_Ojeda_B=C3=A4r?= Date: Sun, 9 Apr 2017 09:45:06 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Matej Kosik <5764c029b688c1c0d24a2e97cd764f@gmail.com> Cc: Josh Berdine , "caml-list@inria.fr" Content-Type: multipart/alternative; boundary=001a11400a98c2b5df054cb70a7b X-DRWEB-SCAN: ok X-VRSPAM-SCORE: -51 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrfeeliedrtdelgdekudcutefuodetggdotefrucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegoufhushhpvggtthffohhmrghinhculdegledmnecujfgurhepjghfhfffkffuvfgtsegrtderredttdejnecuhfhrohhmpefpihgtohhljohspgfqjhgvuggrpgeumohruceonhhitgholhgrshdrohhjvggurgdrsggrrheslhgvgihifhhirdgtohhmqeenucffohhmrghinhepohgtrghmlhdrohhrghdpihhnrhhirgdrfhhrpdhgihhthhhusgdrtghomhdphigrhhhoohdrtghomhenucfkphepvddtledrkeehrddvvddtrddujeelnecurfgrrhgrmhepmhhouggvpehsmhhtphhouhht X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht Subject: Re: [Caml-list] Format questions --001a11400a98c2b5df054cb70a7b Content-Type: text/plain; charset=UTF-8 Hi Matej, I do not think that is the reason, as both calls do the same thing, see https://github.com/ocaml/ocaml/blob/trunk/stdlib/format.ml#L1153 Cheers, Nicolas On Sun, Apr 9, 2017 at 9:44 AM, Matej Kosik < 5764c029b688c1c0d24a2e97cd764f@gmail.com> wrote: > Hi Josh, > > On 04/09/2017 12:24 AM, Josh Berdine wrote: > > On Sat, Apr 08 2017, Matej Kosik wrote: > > > >> Hi everybody, > >> > >> I am trying to understand the concepts in the Format module. > >> > >> While reading this: > >> > >> https://ocaml.org/learn/tutorials/format.html > >> > >> One of the mini experiments I did was: > >> > >> set_margin 11; > >> open_hvbox 0; > >> print_string "---"; > >> print_space (); > >> print_string "---"; > >> print_space (); > >> print_string "---"; > >> print_newline (); > >> print_newline (); > >> > >> I've got the expected output, which is: > >> > >> --- > >> --- > >> --- > >> > >> No surprises. > >> > >> However, when I tried to write express the same intentions via > Format.fprintf function: > >> > >> Format.set_margin 11; > >> Format.fprintf std_formatter "@[---@ ---@ ---@.@."; > >> > >> I get: > >> > >> --- --- --- > >> > >> I'd like to ask for some clues as to why the output of the above > Format.fprintf is different from the more verbose version above. > > > > Are you, by chance, evaluating this in utop (which seems to mess with > std_formatter)? I see your expected behavior using the standard > toplevel. (After adding Format. to std_formatter) > > I was using standard Ocaml toplevel > (in a context where I opened Format module). > > I looked at it today and I have realized that instead of this: > > set_margin 11; > > if I want to use "Format.fprintf std_formatter" I should do > > pp_set_margin std_formatter 11; > > as if > > set_margin <> pp_set_margin std_formatter > > That I did not know. > > -- > 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 > --001a11400a98c2b5df054cb70a7b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Matej,

I do not think that is the re= ason, as both calls do the same thing, see

=C2=A0 = https://github.com/ocaml/ocaml/blob/trunk/stdlib/format.ml#L1153
<= /div>

Cheers,
Nicolas


On Sun, Apr 9, = 2017 at 9:44 AM, Matej Kosik <5764c029b688c1c0d24a2= e97cd764f@gmail.com> wrote:
Hi Josh,

On 04/09/2017 12:24 AM, Josh Berdine wrote:
> On Sat, Apr 08 2017, Matej Kosik wrote:
>
>> Hi everybody,
>>
>> I am trying to understand the concepts in the Format module.
>>
>> While reading this:
>>
>>=C2=A0 =C2=A0https://ocaml.org/learn/tutor= ials/format.html
>>
>> One of the mini experiments I did was:
>>
>>=C2=A0 =C2=A0set_margin 11;
>>=C2=A0 =C2=A0open_hvbox 0;
>>=C2=A0 =C2=A0print_string "---";
>>=C2=A0 =C2=A0print_space ();
>>=C2=A0 =C2=A0print_string "---";
>>=C2=A0 =C2=A0print_space ();
>>=C2=A0 =C2=A0print_string "---";
>>=C2=A0 =C2=A0print_newline ();
>>=C2=A0 =C2=A0print_newline ();
>>
>> I've got the expected output, which is:
>>
>>=C2=A0 =C2=A0---
>>=C2=A0 =C2=A0---
>>=C2=A0 =C2=A0---
>>
>> No surprises.
>>
>> However, when I tried to write express the same intentions via For= mat.fprintf function:
>>
>>=C2=A0 =C2=A0Format.set_margin 11;
>>=C2=A0 =C2=A0Format.fprintf std_formatter "@[<hv 0>---@ = ---@ ---@.@.";
>>
>> I get:
>>
>>=C2=A0 =C2=A0--- --- ---
>>
>> I'd like to ask for some clues as to why the output of the abo= ve Format.fprintf is different from the more verbose version above.
>
> Are you, by chance, evaluating this in utop (which seems to mess with = std_formatter)?=C2=A0 =C2=A0I see your expected behavior using the standard= toplevel.=C2=A0 (After adding Format. to std_formatter)

I was using standard Ocaml toplevel
(in a context where I opened Format module).

I looked at it today and I have realized that instead of this:

=C2=A0 set_margin 11;

if I want to use "Format.fprintf std_formatter" I should do

=C2=A0 pp_set_margin std_formatter 11;

as if

=C2=A0 set_margin <> pp_set_margin std_formatter

That I did not know.

--
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/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

--001a11400a98c2b5df054cb70a7b--