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 OAA24744; Fri, 12 Jul 2002 14:41:19 +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 OAA24722 for ; Fri, 12 Jul 2002 14:41:18 +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 g6CCfCf25392; Fri, 12 Jul 2002 14:41:12 +0200 (MET DST) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA24723; Fri, 12 Jul 2002 14:41:11 +0200 (MET DST) From: Pierre Weis Message-Id: <200207121241.OAA24723@pauillac.inria.fr> Subject: Re: [Caml-list] printf hook In-Reply-To: <004001c2298d$de86f7f0$3700a8c0@warp> from Nicolas Cannasse at "Jul 12, 102 12:21:20 pm" To: warplayer@free.fr (Nicolas Cannasse) Date: Fri, 12 Jul 2002 14:41:11 +0200 (MET DST) Cc: Jean-Christophe.Filliatre@lri.fr, 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 > I just found something quite funny : > > let print x = > printf "BEGIN"; > printf x; > flush stdout > > print "test";; > print "%d" 10; (** TOO MUCH ARGS **) This is normal, isn't it ? > ============ > > let print x = > printf "BEGIN"; > let r = printf x in > flush stdout; > r > > print "test"; > print "%d" 10; (** WORKING **) This is also perfectly regular: your code let print x = printf "BEGIN"; let r = printf x in flush stdout; r is functionally equivalent to let print x = let r = printf x in r which is again functionally equivalent to let print x = printf x which is again equivalent to let print = printf The type checker gives an hint on that fact, since print is reported having the same type as printf: Objective Caml version 3.04+15 (2002-06-18) #open Printf;; # let print x = printf "BEGIN"; let r = printf x in flush stdout; r;; val print : ('a, out_channel, unit) format -> 'a = # printf;; - : ('a, out_channel, unit) format -> 'a = 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