Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] printf hook
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Damien Doligez <damien.doligez@i...>
Subject: Re: [Caml-list] printf hook
>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