Version française
Home     About     Download     Resources     Contact us    
Browse thread
[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: Nicolas Cannasse <warplayer@f...>
Subject: Re: [Caml-list] printf hook
>  > 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 ?
> 
> You can do the following :
> 
> # open Printf;;
> # let print x = printf "BEGIN: "; printf x;;               

I just found something quite funny :

let print x =
    printf "BEGIN";
    printf x;
    flush stdout

print "test";;
print "%d" 10; (** TOO MUCH ARGS **)

============

let print x =
    printf "BEGIN";
    let r = printf x in
    flush stdout;
    r

print "test";
print "%d" 10; (** WORKING **)

NC

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