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
[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-15 (23:01)
From: Markus Mottl <markus@o...>
Subject: Re: [Caml-list] kprintf with user formatters
On Fri, 16 Jul 2004, Pierre Weis wrote:
> I don't know of any way to safely prevent the arguments of printf from
> being converted to string when interpreting the format.

This would probably require some changes in the implementation of

> Since you have a if then else, the ``???'' expression should have
> exactly the same type as the ``then kfprintf ...'' expression. Hence
> the simplest way to do so is to have another kfprintf invocation with
> the same format. Evidently you want to redirect the output of this
> invocation to /dev/null (I mean you do not want to see its output).

Not only this: I want to prevent any computations associated with
generating output strings.

> The best way to do so is not to redefine a specialized version of
> printf, it is simply to define a specialized pretty printer that would
> behave as you want and then to specialize fprintf with it:
> let null_formatter =
>   let null_out s idx len = () in
>   let null_flush = ignore in
>   Format.make_formatter null_out null_flush;;

This would surely ignore any output, but "null_out" would still be called
with superfluously generated strings.

Anyway, the argument-eating function that makes use of "Obj.magic"
works for me so my problem is solved.


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