Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: David Allsopp <dra-news@metastack.com>
To: OCaml List <caml-list@inria.fr>
Subject: RE: [Caml-list] Vagaries of Printf variants
Date: Tue, 28 Oct 2014 09:04:27 +0000	[thread overview]
Message-ID: <E51C5B015DBD1348A1D85763337FB6D9E9667C88@Remus.metastack.local> (raw)
In-Reply-To: <8D9D2D7B6A29486D80BB692EC24DBE06@erratique.ch>

Daniel Bünzli wrote:
> Le lundi, 27 octobre 2014 à 18:56, David Allsopp a écrit :
> > but I'm sure there's a reason for its being that way!
> 
> You may be interested in reading this:
> 
> http://gallium.inria.fr/blog/format6/

Thanks, that is enlightening! I guess the thing that gets "in the way" is the design decision to make %a operate on the printf-behaviour (i.e. for fprintf, it writes to a channel, for bprintf it writes to a buffer) rather than making %a and %t *always* return a string.

> P.S. If you are using formatters the problem is less acute. Nowadays you
> can simply define formatters for each of your types with:
> 
> pp : Format.formatter -> t -> unit
> 
> and a to_string function is one `Format.asprintf "%a" pp` away.

I was abusing terminology - by formatters I meant printf functions i.e. selecting between ikfprintf, kfprintf, etc. in the same functions.

I haven't looked at the 4.02 sources, but for what I'm doing in 4.01, what would actually be useful would be if Printf.mkprintf were public so that I could supply an alternate function for output_string (i.e. allow Printf.printf to proceed entirely as normal but do something ever-so-slightly different with the final result - and with a different format6 from using ksprintf).


David

  reply	other threads:[~2014-10-28  9:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-27 17:56 David Allsopp
2014-10-27 18:51 ` Daniel Bünzli
2014-10-28  9:04   ` David Allsopp [this message]
2014-10-28  9:19     ` Gabriel Scherer
2014-10-28  9:33       ` David Allsopp
2014-10-28 20:18       ` [Caml-list] <DKIM> " Pierre Chambart
2014-10-29 10:34         ` David Allsopp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E51C5B015DBD1348A1D85763337FB6D9E9667C88@Remus.metastack.local \
    --to=dra-news@metastack.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox