English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2002-06-26 (16:32)
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