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 TAA27418; Mon, 29 Sep 2003 19:49:04 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA04701 for ; Mon, 29 Sep 2003 19:49:01 +0200 (MET DST) Received: from mwinf0602.wanadoo.fr (smtp3.wanadoo.fr [193.252.22.25]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h8THn0511626 for ; Mon, 29 Sep 2003 19:49:00 +0200 (MET DST) Received: from lexifi.com (ATuileries-105-1-4-238.w80-14.abo.wanadoo.fr [80.14.75.238]) by mwinf0602.wanadoo.fr (SMTP Server) with ESMTP id 0D95454001B5; Mon, 29 Sep 2003 19:49:00 +0200 (CEST) Message-ID: <3F786FC3.4020807@lexifi.com> Date: Mon, 29 Sep 2003 19:45:39 +0200 From: Jean-Marc EBER User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Brian Hurt Cc: Martin Jambon , caml-list@inria.fr Subject: Re: [Caml-list] Printing text with holes References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 stdout:01 printf:01 printf:01 ocaml's:01 recursively:01 pretty-print:01 int:01 eber:02 eber:02 jeanmarc:02 precisely:02 module:03 string:03 jean-marc:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > > This would allow you to do: > let _ = stdout <$ "Hello " <$ first_name <$ " " <$ last_name <$ "! It is " > <$ (string_of_int time) <$ " o'clock.\n";; > > Not quite as clean, but close, and it doesn't require p4. > With "old" printf approach, you write something like: let _ = printf "Hello %s %s! It is %i o'clock.\n" first_name last_name time Matter of taste: I prefer the printf version. More generally, I have found the printf approach (more precisely OCaml's Format 'magic' standard module) of incredible power and flexibility, if (and only if :-) ) used consistently through *all* your program. This is especially true when you generate "big" documents, where you compose recursively many "nice" ways to pretty-print your result(s). Jean-Marc Eber ------------------- 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