> Martin Norb�ck <[EMAIL PROTECTED]> wrote:
> > I agree that i18n needs positional arguments.
> > What's wrong with simply doing like this:
> >
> > printf "I have %. %. %.." ["trained", show 1, "Jedi"]
> > printf "%2. %3. %1. I have." ["trained", show 1, "Jedi"]
>
> Nothing is exceptionally wrong with it, except it's not
> as flexible. Since everything is show'n, how would you
> handle things like "%5.2f" or "%*d"? In Brian Huffman's
> version it's almost trivial to add. I know I can use
> formatDouble and whatnot, but the code looks cluttered
> this way. "C" printf has many pitfalls, but I like its
> terseness.
Just thought I would jump in and say that, unlike (it seems) everyone else, I
hate printf in C. It is a horrible horrible inextensible hack of a function
that I find extremely awkward to use.
In the C version, it is completely hardcoded and inextensible. Even in the
version presented on this list, one can't add new ways to format an existing
datatype.
I personally much prefer the syntax currently used in Haskell, which is also
essentially what is used in most other recent languages, including Java, C++,
and (god help me) Perl.
In the example given, I could write:
"I have " ++ action ++ " " ++ number ++ " " ++ whatas
where
action = "trained"
number = show 1
whatas = "Jedi"
Which is IMHO rather more readable than a load of weird control codes hidden
in a text string that one then has to match against a list.
+ If I want to use a weird formatting approach, I just write my own function,
and use it instead of "show". No need to faff around extending someone else's
printf.
[end rant]
-Rob
_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell