From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id D804ABB81 for ; Thu, 12 Jan 2006 18:14:14 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k0CHEEpt003827 for ; Thu, 12 Jan 2006 18:14:14 +0100 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 SAA21995 for ; Thu, 12 Jan 2006 18:14:13 +0100 (MET) Received: from furbychan.cocan.org (furbychan.cocan.org [80.68.91.176]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k0CHECu2009154 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Thu, 12 Jan 2006 18:14:13 +0100 Received: from rich by furbychan.cocan.org with local (Exim 3.35 #1 (Debian)) id 1Ex6QW-00024G-00; Thu, 12 Jan 2006 17:39:56 +0000 Date: Thu, 12 Jan 2006 17:39:56 +0000 To: Bill Wood Cc: Ocaml Subject: Re: [Caml-list] Request for comments: Printf list conversion Message-ID: <20060112173956.GA9364@furbychan.cocan.org> References: <43C61F1F.4030101@barettadeit.com> <1137081054.29722.13.camel@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1137081054.29722.13.camel@localhost> User-Agent: Mutt/1.5.9i From: Richard Jones X-Miltered: at concorde with ID 43C68E66.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 43C68E64.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 printf:01 ocaml:01 hacked:01 hacked:01 debugging:01 cvs:01 viewcvs:01 mli:01 notepad:01 wrote:01 sourceforge:01 hacks:01 prolog:01 recursively:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Thu, Jan 12, 2006 at 09:50:54AM -0600, Bill Wood wrote: > Just a comment. I've been anticipating getting into something like this > since I started considering OCaml as a work-horse language. I've gone > through this exercise several times -- When I worked in Prolog, I hacked > together a list formatter; after using Scheme a while I hacked out a > list formatter package (and I'm dreading doing it yet again :-). The > thing is, it's so terribly useful. > > I'm always inspired in my hacks by Common Lisp's (format...) form, which > includes a ~{/~} pair containing conversion directives and that consumes > a list argument. I don't want to appall you with complexity too soon, > but when you think about this, consider the possibility that the list is > a list of lists, each of which contains several items that are to be > formatted using a a recursively specified (sub) format. This does > enhance usability a great deal. I'm sure that there are people who will > yelp in protest at this, but I do recommend looking at CL's format as at > least one point in this design space. If you just want to dump out data structures (for debugging, for example) then you might want to take a look at the Std.dump function in Extlib: http://cvs.sourceforge.net/viewcvs.py/ocaml-lib/extlib-dev/std.mli?rev=1.15&view=markup Or: http://merjis.com/developers/dumper Of course this isn't suitable for end user reports. Rich. -- Richard Jones, CTO Merjis Ltd. Merjis - web marketing and technology - http://merjis.com Team Notepad - intranets and extranets for business - http://team-notepad.com