[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: printf is a crappy language in a crappy language (was Re: [OT] Lua community and Go language)
- From: Coda Highland <chighland@...>
- Date: Mon, 19 Aug 2013 01:17:48 -0700
On Mon, Aug 19, 2013 at 12:48 AM, steve donovan
<steve.j.donovan@gmail.com> wrote:
> On Mon, Aug 19, 2013 at 9:37 AM, Coda Highland <chighland@gmail.com> wrote:
>> C++'s << is nice, but doesn't address reordering parameters for localization.
>
> <c++>
>
> printF(cout,L("Hello {0}, ({1})\n"),Strings() << name << age);
>
> (exercise for the reader. Strings is a type with a templated <<
> operator which uses ostream<< to make up a list of appropriate
> strings, printF then should be pretty easy. L() just matches a string
> in a suitable localization file)
>
> Or even (with implicit L() and a suitable wrapper type PrintF)
>
> PrintF(cout, "Hello {0}, ({1})\n") << name << age;
>
> </c++>
>
Well sure, I mean, Qt does it more or less that way -- tr("Hello %0,
(%1)\n").arg(name).arg(age) not only provides the format string but
also hooks the localization system. But when you said "C++" I assumed
you meant standard C++, not something you could build on top of it.
But if we're taking C++11 into account, you could write a full-blown
type-aware printf replacement with printf-styled syntax thanks to
variadic templates.
/s/ Adam
- References:
- [OT] Lua community and Go language, Lorenzo Donati
- Re: [OT] Lua community and Go language, Sven Olsen
- Re: [OT] Lua community and Go language, Gé Weijers
- Re: [OT] Lua community and Go language, Miles Bader
- Re: [OT] Lua community and Go language, Craig Barnes
- Re: [OT] Lua community and Go language, Rena
- Re: [OT] Lua community and Go language, Lorenzo Donati
- Re: [OT] Lua community and Go language, steve donovan
- printf is a crappy language in a crappy language (was Re: [OT] Lua community and Go language), Jay Carlson
- Re: printf is a crappy language in a crappy language (was Re: [OT] Lua community and Go language), William Ahern
- Re: printf is a crappy language in a crappy language (was Re: [OT] Lua community and Go language), Jay Carlson
- Re: printf is a crappy language in a crappy language (was Re: [OT] Lua community and Go language), Andres Perera
- Re: printf is a crappy language in a crappy language (was Re: [OT] Lua community and Go language), Jay Carlson
- Re: printf is a crappy language in a crappy language (was Re: [OT] Lua community and Go language), Andres Perera
- Re: printf is a crappy language in a crappy language (was Re: [OT] Lua community and Go language), Tim Hill
- Re: printf is a crappy language in a crappy language (was Re: [OT] Lua community and Go language), steve donovan
- Re: printf is a crappy language in a crappy language (was Re: [OT] Lua community and Go language), Coda Highland
- Re: printf is a crappy language in a crappy language (was Re: [OT] Lua community and Go language), steve donovan