lua-users home
lua-l archive

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



Personally, I found my solution to this itch :) with the "%" operator usage that was mentioned on the list only a few weeks back. It is common to all Lua strings, but does not break current behaviour, nor needs core-level changes. I love it! :)

Instead of this, I would recommend using one of the operators currently
undefined for strings (it could be the % operator, say) and use it to
interpolate values from a table. This is done by detecting placeholders in
the string. For example:-

	"Name: [1], Rank: [2], Serial: [3]" % {"Andy", "Captain", 1234}

Of course it doesn't have to use square brackets. One possibility is to use % within the string like printf does - familiar and consistent with
the choice of operator.

by Andy Stark, Oct 9th.


Luiz Henrique de Figueiredo kirjoitti 23.10.2006 kello 20.35:

This transformation can be done by the parser, rather than processing it
at runtime.

Another fine job for a token filter...
--lhf