lua-users home
lua-l archive

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

On 4 March 2014 13:21, Dirk Laurie <> wrote:
> 2014-03-04 16:48 GMT+02:00 Andrew Starks <>:
>> On Tue, Mar 4, 2014 at 8:06 AM, joao lobato <> wrote:
>>> Perhaps "%s" should explicitly mean "invoke tostring on this".
>>> (Maybe it already does :-) )
>> Yes. My first observation was focusing on number's __tostring method
>> defaulting to "%f" instead of "%.f".
> Actually,  LUA_NUMBER_FMT defaults to "%.14g", hardwired. A clean
> solution would be to make it settable via debug.number_format(s).

That would be a huge step back in interoperability. I could see it
breaking modules everywhere.

One might argue that this would be similar to other global changes /
"monkey patching", but modules have ways to defend themselves from
those. Changing the number format would make little unexpected
behaviors pop up here and there (potentially in hard-to-spot corner
cases), with no way to defend against.

Also, it's not a debug feature. (Though I understand that the debug
table is sometimes seen as the
powerful-things-you-shouldn't-use-in-well-behaved-code table.)

-- Hisham