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 <dirk.laurie@gmail.com> wrote:
> 2014-03-04 16:48 GMT+02:00 Andrew Starks <andrew.starks@trms.com>:
>> On Tue, Mar 4, 2014 at 8:06 AM, joao lobato <btnfdp.lobato@gmail.com> 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