Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2004-07-16 (17:57)
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
> 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.


Markus Mottl

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: