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 SAA23999; Mon, 29 Sep 2003 18:34:39 +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 SAA04189 for ; Mon, 29 Sep 2003 18:34:37 +0200 (MET DST) Received: from herd.plethora.net (herd.plethora.net [205.166.146.1]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h8TGYZ507125 for ; Mon, 29 Sep 2003 18:34:36 +0200 (MET DST) Received: from bhurt.plethora.net (bhurt.plethora.net [205.166.146.49]) by herd.plethora.net (8.11.6/8.10.1) with ESMTP id h8TGYVC19230; Mon, 29 Sep 2003 11:34:32 -0500 (CDT) Date: Mon, 29 Sep 2003 11:39:32 -0500 (CDT) From: Brian Hurt X-X-Sender: bhurt@localhost.localdomain To: Martin Jambon cc: caml-list@inria.fr Subject: Re: [Caml-list] Printing text with holes In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 dynamically:01 printf:01 stdout:01 imho:01 int:01 sep:01 jambon:02 string:03 string:03 wrote:03 let:04 let:04 horrible:04 str:05 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, 29 Sep 2003, Martin Jambon wrote: > Hello, > > I am curious to know what people use to print long text written in a > natural language, and containing many holes, like dynamically generated > web pages. I agree. I think printf is a horrible way to do output. Reasons include, but are not limited to, the fact that you are basically creating a new "mini-language" (the formatting language) which has to be type checked etc. seperately from the main language, that the values being put into the string are listed far from their positions in the string (your problem) leading to missing parameters, parameters in the wrong order, etc. > The solution I adopted some time ago is the following: IMHO, this is certainly a better solution to the problem. But it does need p4 (I think). What might be even better is an output operator, ala C++. Maybe something like: let ( <$ ) chan str = output_string chan str; chan 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. Brian ------------------- 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