[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?
- From: Tim Hill <drtimhill@...>
- Date: Mon, 9 Sep 2013 11:38:48 -0700
On Sep 9, 2013, at 6:02 AM, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> Well, we do not. We could debate whether tostring{} -> 0x83ffda8 or even
> tostring("123") is CORRECT. Anyway, the manual is very clear about it:
>
> "Receives an argument of any type and converts it to a string in a
> reasonable format."
>
> The key word there is *reasonable*.
>
> -- Roberto
>
People will of course argue what "reasonable" means :) To my mind the real problem here, which Lua has in common with Java, C# etc, is what exactly the contract for a ".tostring()" construct could actually be? Is the string to be used for human display? As a persistence format? for debugging? No language I am aware of specifies this, with the result that in (say) Java different classes do wildly different things with tostring(). So far as I can see, emitting the current weather report would be valid according to the Java or C# docs :)
--Tim
- References:
- why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, pulleyzzz_gmail
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Leo Razoumov
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Coda Highland
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Dirk Laurie
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Coda Highland
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Dirk Laurie
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Coda Highland
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Roberto Ierusalimschy