From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA26995; Fri, 21 Jun 2002 14:11:10 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA26798 for ; Fri, 21 Jun 2002 14:11:10 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g5LCB9j09755; Fri, 21 Jun 2002 14:11:09 +0200 (MET DST) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA26886; Fri, 21 Jun 2002 14:11:08 +0200 (MET DST) From: Pierre Weis Message-Id: <200206211211.OAA26886@pauillac.inria.fr> Subject: Re: [Caml-list] printf arguments In-Reply-To: from Henri Dubois-Ferriere at "Jun 20, 102 08:12:46 pm" To: henri.dubois-ferriere@epfl.ch Date: Fri, 21 Jun 2002 14:11:08 +0200 (MET DST) Cc: caml-list@inria.fr X-Mailer: ELM [version 2.4ME+ PL28 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > In trying to write a wrapper around printf for debug message logging, > (a la syslog), I am coming across the following problem: > > # let myprintf fmt = if (true) then Printf.fprintf stdout fmt;; > val myprintf : (unit, out_channel, unit) format -> unit = If cond then expr == if cond then expr else () [...] > so the myprintf function above does not have the same type as the original > fprintf. Note that removing the if clause returns us to the proper type: > > # let myprintf fmt = Printf.fprintf stdout fmt;; > val myprintf : ('a, out_channel, unit) format -> 'a = If you want to preserve the original typing of printf, you must imperatively use a tail call to printf (due to the typing discipline of string format). Regards, Pierre Weis INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/ ------------------- 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