lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


So, POSIX (and other C implementations) have an extension to printf()
format specifiers allowing them to specify an argument by its
position.  So, you can use:

printf("%2$s %1$s\n", "world!", "Hello");  /* prints "Hello world!\n" */

It turns out to be very handy for i18n purposes, because different
languages can have different word orders.

Alas, Lua does not support POSIX format specifier position indicators.
If you have a format string which originally meant for C's printf()
function, it is in general a bad idea to pass it straight into Lua's
string.format() function.  They are similar functions, but definitely
not compatible.

   -Mark