Version française
Home     About     Download     Resources     Contact us    
Browse thread
Request for comments: Printf list conversion
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] Request for comments: Printf list conversion
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