[Haskell-cafe] Re: Pure Haskell Printf

John Goerzen jgoerzen at complete.org
Wed Nov 17 14:12:10 EST 2004


On 2004-11-17, Vincenzo Ciancia <vincenzo_mlRE.MOVE at yahoo.it> wrote:
> On Tuesday 16 November 2004 10:37, Henning Thielemann wrote:
>> Variable length argument lists are really a mess. Why are people so
>> keen on them? What is the advantage over a plain list as single
>> argument? Is vsprintf "%s, your age is %s\n" ["John", show
>> (10::Integer)] really too complicated?
>
> The implementation of printf in ocaml, for example, is not only 
> type-safe, but "more type safe" than passing a list, because the number 
> and type of arguments is known at compile time.

On the other hand, the OCaml printf is, unless I'm very mistaken,
handled specially by the compiler.  That is, the compiler looks out for
format strings and converts them to the weirdo format4 things that OCaml
uses.

That means that one could not implement one's own printf using pure
OCaml.  Though a person could use camlp4, but then that's back to the
same place as TH.

OCaml's printf also is limited in that it can take only a string literal
for the format string, and not a string in a variable.

-- John



More information about the Haskell-Cafe mailing list