Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] kprintf with user formatters
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Markus Mottl <markus@o...>
Subject: Re: [Caml-list] kprintf with user formatters
On Fri, 16 Jul 2004, Jean-Christophe Filliatre wrote:
> I  also  use  the same  kind  of  trick  in  practice, with  a  little
> refinement  to avoid  building the  closure. I  introduce higher-order
> functions such as
> 
>    val if_debug : ('a -> unit) -> 'a -> unit

This actually looks quite nice to me!  Though one needs to add several
functions for varying numbers of arguments, this makes hardly any
difference syntactically, and it is still sufficiently easy to maintain.

On Fri, 16 Jul 2004, Damien wrote:
> > It is overkill to introduce a new printf function just for that case.
> maybe...
> but it is not to hard to implement (after a quick look at printf.ml)
> without the "invalid unit value" problem:

Yes, a change like this in the Printf/Format-implementation was what I
was thinking about.  Just count the number of arguments in the format
and discard them.  This is sufficiently efficient (no allocations)
and convenient.

Regards,
Markus

-- 
Markus Mottl          http://www.oefai.at/~markus          markus@oefai.at

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