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 E09F47F6CB for ; Tue, 10 Feb 2015 08:55:36 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of jpathy@fssrv.net) identity=pra; client-ip=74.125.82.171; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jpathy@fssrv.net"; x-sender="jpathy@fssrv.net"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of jpathy@fssrv.net designates 74.125.82.171 as permitted sender) identity=mailfrom; client-ip=74.125.82.171; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jpathy@fssrv.net"; x-sender="jpathy@fssrv.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@mail-we0-f171.google.com) identity=helo; client-ip=74.125.82.171; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jpathy@fssrv.net"; x-sender="postmaster@mail-we0-f171.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0B9AgB5uNlUm6tSfUpcg1haBIJ+wAcKhXECgRYHQwEBAQEBARABAQEBAQYLCwkULoQNAQEEAQIPEQQZAQE3AQ8LCwMKAgImAgIiEgEFARwGExoIiAsNqkc+MYo+cIRiAQWSFwEBAQEGAQEBAQEXBgqBF45WB4JogUKKLIhEhVyBGDaFE4hRgXQSI4EVhDEdMQEBgkABAQE X-IPAS-Result: A0B9AgB5uNlUm6tSfUpcg1haBIJ+wAcKhXECgRYHQwEBAQEBARABAQEBAQYLCwkULoQNAQEEAQIPEQQZAQE3AQ8LCwMKAgImAgIiEgEFARwGExoIiAsNqkc+MYo+cIRiAQWSFwEBAQEGAQEBAQEXBgqBF45WB4JogUKKLIhEhVyBGDaFE4hRgXQSI4EVhDEdMQEBgkABAQE X-IronPort-AV: E=Sophos;i="5.09,548,1418079600"; d="scan'208";a="99496856" Received: from mail-we0-f171.google.com ([74.125.82.171]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 10 Feb 2015 08:55:36 +0100 Received: by mail-we0-f171.google.com with SMTP id k11so31851852wes.2 for ; Mon, 09 Feb 2015 23:55:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fssrv.net; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=KcGDRmra9+ocFovQzl78OpjA3UCb4jAAoh8O5x9ytWM=; b=VHdhZdcToNrHvS8VeBHds33KGkcmm1+30lvfBvnGuxodjrUpeyZWroFtoPuDVUL8FJ yy1uj+5OmOgJin82d9wEVVvq7bMUumTqFCNRlkDKcPSE1hQSO+IM1xyZqyNb/9Ibt+3c hAwu2kdXeAIWsqhT6pTqG6y+ZHC6hTAmkqI4o= 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:date :message-id:subject:from:to:cc:content-type; bh=KcGDRmra9+ocFovQzl78OpjA3UCb4jAAoh8O5x9ytWM=; b=VaT9UWGRMjCDy2X56LEO0nYS/TJ9epQM9EaBAx0gv4o1ju//lxrnx9AqnrnkxMkZ9D V0qfJ4B3iCvqyDug0ktwgqq3TWPl8dSosZ2srAHvPJMpNt4Vv476Pym0pIsnl7A9oYAh 6fF1ADA5v2HNmhiHocgd79FslkDIxboErmKIZa4F/wTNKKz6bkeDsy5zhcsWiwKqqDo0 KkVKF8vHEYRwUcrBaQNNzsY3QyxXMEBYX/oF3nECyQBiT2ODSHawDq4thi2LXe3cca+t ZU+Ne12dhPGoWMB6ATDMg511IiGdiU0dK4AV9HJ5sj+wEFRQfNyz7EvpbfwgxGiFffsD 0vog== X-Gm-Message-State: ALoCoQnOh0d7xChUxjVY/8S8lz4E5E71eMUrCjV12xXoWN5haPA1J87bc3oJX95jA/4LV2rxnaNs MIME-Version: 1.0 X-Received: by 10.180.14.104 with SMTP id o8mr20592943wic.47.1423554936090; Mon, 09 Feb 2015 23:55:36 -0800 (PST) Received: by 10.27.226.67 with HTTP; Mon, 9 Feb 2015 23:55:36 -0800 (PST) In-Reply-To: References: Date: Mon, 9 Feb 2015 23:55:36 -0800 Message-ID: From: Jiten Pathy To: David Allsopp Cc: "caml-list@inria.fr" Content-Type: text/plain; charset=UTF-8 Subject: Re: [Caml-list] format strings Ok, If i am not supposed to use make_printf, then what is the recommended way of writing the following? This adds a new line to given format string. In particular how do i manipulate the format strings passed to me? open CamlinternalFormat;; let f (Format (fmt, _)) = make_printf (fun o acc -> output_acc o (Acc_char_literal (acc, '\n')); ignore o) stdout End_of_acc fmt ;; val f : ('a, out_channel, unit, unit, unit, unit) format6 -> 'a = utop # f "%s %d" "# " 3;; # 3 - : unit = () I now have a slightly better understanding of CamlinternalFormat. On Mon, Feb 9, 2015 at 11:44 PM, David Allsopp wrote: > Jiten Pathy wrote: >> nvm. make_printf is what I am after. > > No it isn't - using internal functions is, to 1 significant figure, never what you're after. Apart from anything, you're instantly forcing your code to be 4.02+ > >> Some complicated stuff is going on in CamlInternalFormat. > > Indeed - 4.02 has a very clever reimplementation of the printf engine. > >> On Mon, Feb 9, 2015 at 5:05 PM wrote: >> > Is there a way I can define a function which has the same signature of >> > printf family but is a no-op? >> > >> > f : ('a, 'b, unit) format -> 'a > > Printf.ifprintf (you can do similar with Printf.ksprintf and Printf.ikfprintf). > > I don't know what lead you to read CamlInternalFormat.mli, but the reference manual (http://caml.inria.fr/pub/docs/manual-ocaml-4.02/libref/Printf.html) is a much better place to start for information on these modules than their source code. > > > David