caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] printf hook
@ 2002-06-26 15:01 Nicolas Cannasse
  2002-06-26 15:21 ` Jean-Christophe Filliatre
  2002-06-26 15:51 ` Remi VANICAT
  0 siblings, 2 replies; 7+ messages in thread
From: Nicolas Cannasse @ 2002-06-26 15:01 UTC (permalink / raw)
  To: OCaml

Hi list !
I would like do to something like this :

let sprint msg =
    print_endline ("BEGIN: "^(sprintf msg))

without of course loosing the ability of having variable number of
parameters in my "msg".
Is that kind of thing possible ?

Thanks a Lot
Nicolas Cannasse

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re:  [Caml-list] printf hook
@ 2002-06-26 16:31 Damien Doligez
  2002-06-26 16:46 ` Nicolas Cannasse
  0 siblings, 1 reply; 7+ messages in thread
From: Damien Doligez @ 2002-06-26 16:31 UTC (permalink / raw)
  To: caml-list, warplayer

>From: "Nicolas Cannasse" <warplayer@free.fr>
>
>let sprint msg =
>    print_endline ("BEGIN: "^(sprintf msg))
>
>without of course loosing the ability of having variable number of
>parameters in my "msg".

If you can wait for 3.05, or if you are willing to use the CVS
version, you'll be able to write:

  let sprint fmt =
    let do_output s = print_endline ("BEGIN: " ^ s); "" in
    Printf.kprintf do_output fmt
  ;;

The tail-call to kprintf allows it to get the extra arguments thanks
to currying.  The do_output function must return a string (which is
returned by sprint) for technical reasons.  (This may change before
the release.)

-- Damien
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-07-12 12:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-26 15:01 [Caml-list] printf hook Nicolas Cannasse
2002-06-26 15:21 ` Jean-Christophe Filliatre
2002-07-12 10:21   ` Nicolas Cannasse
2002-07-12 12:41     ` Pierre Weis
2002-06-26 15:51 ` Remi VANICAT
2002-06-26 16:31 Damien Doligez
2002-06-26 16:46 ` Nicolas Cannasse

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).