[Haskell-cafe] Re: Pure Haskell Printf

Peter Simons simons at cryp.to
Tue Nov 16 05:02:27 EST 2004


Henning Thielemann writes:

 > Variable length argument lists are really a mess. Why are
 > people so keen on them?

One advantage is that you need to type fewer characters.
It's, well, not _that_ important, I'll readily admit. :-)
But

  vsnprintf "i = %d;\tj = %s" 12 "test"

is more compact than any other notation I'd be aware of. And
it comes, of course, at the price of being rather dangerous,
depending on what you do.

Personally, I have found ShowS style text-formatting to be
my favorite. The code

  verb = showString
  msg  = (verb "i = ") . (12 `shows`) . (verb "\tj = ") $ "test"

isn't mind-blowingly compact either, but I always feel an
odd satisfaction when writing this, because it's supposedly
very efficient -- which justifies the extra characters,
IMHO. :-)

Peter



More information about the Haskell-Cafe mailing list