caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Tiphaine Turpin <Tiphaine.Turpin@irisa.fr>
To: "Jérémie Dimino" <jeremie@dimino.org>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] printf "%a" vs sprintf "%a"
Date: Thu, 26 Mar 2009 18:37:21 +0100	[thread overview]
Message-ID: <49CBBD51.5090005@irisa.fr> (raw)
In-Reply-To: <1238088594.8677.26.camel@localhost.localdomain>

Thanks for the replies. sprintf2 is just fine for me.

Tiphaine


Jérémie Dimino a écrit :
> Tiphaine Turpin wrote:
>   
>> has type string. But %a breaks this rule. Wouldn't it be simpler to have
>> two separate directives which accept respectively string printers and
>> channel printers, regardless of the outer printing function ?
>>     
>
> Note that you can do it with batteries and the new printf.
>
> The default "%a" directive always uses a channel printer:
>
> # Print.printf p"%a";;
> - : (unit Batteries.IO.output -> '_a -> unit) -> '_a -> unit = <fun>
> # Print.sprintf p"%a";;
> - : (unit Batteries.IO.output -> '_a -> unit) -> '_a -> string = <fun>
>
> And you can define a "%foo" directive which always uses a string printer:
>
> # let printer_foo k f x = k (fun out -> String.print out (f x));;
> val printer_as : (('a Batteries.IO.output -> unit) -> 'b) -> ('c -> string) -> 'c -> 'b = <fun>
> # Print.printf p"%foo";;
> - : ('_a -> string) -> '_a -> unit = <fun>
> # Print.sprintf p"%foo";;
> - : ('_a -> string) -> '_a -> string = <fun>
>
> Cheers,
> Jérémie
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>   


      reply	other threads:[~2009-03-26 17:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-26 16:53 Tiphaine Turpin
2009-03-26 17:29 ` [Caml-list] " David Rajchenbach-Teller
2009-03-26 17:29 ` Jérémie Dimino
2009-03-26 17:37   ` Tiphaine Turpin [this message]

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=49CBBD51.5090005@irisa.fr \
    --to=tiphaine.turpin@irisa.fr \
    --cc=caml-list@yquem.inria.fr \
    --cc=jeremie@dimino.org \
    /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;
as well as URLs for NNTP newsgroup(s).