lua-users home
lua-l archive

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


Seems %m or %t (tostring) would be a fair incremental improvement at little
cost.

BTW. Reminder about Ricis Lake userdata improvement
http://lua-users.org/wiki/UserDataRefinement

DB

On 10/2/06, Doug Currie <doug.currie@gmail.com> wrote:
Monday, September 11, 2006, 12:32:09 PM, Roberto Ierusalimschy wrote:

>> i have seen some lua 5.2 feature requests. is there an "official" place
>> where the feature requests are stored/tracked?

> Only the list itself.

Here is a proposal for 5.2...

It was a surprise to me that string.format()'s option "%s" did not
apply tostring() to its arguments as print() does.

This would make formatted output using, e.g., loadable numerics
libraries like decNumber, much more convenient. Of course, it would
work with any userdata or class that implemented __tostring.

So, my request is that Lua 5.2 either
- apply tostring() to non-string "%s" arguments of string.format(), or
- add a string.format option that applies tostring() to its argument,
and then performs the usual "%s" action.

If the second approach is preferred, I am not particular to any
specific character to specify this format option, though I recommend
"%m" (use Metatable's __tostring) or "%y" (stringifY) -- neither of
these is in common usage with printf as far as I know, unlike "%o"
(Object) and "%S" (wide String).

Regards,

e

--
Doug Currie
Londonderry, NH