lua-users home
lua-l archive

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


On 04/03/2014, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 2014-03-04 11:27 GMT+02:00 Pierre Chapuis <catwell@archlinux.us>:
>
>> I think Lua 5.3 may be a good time to remove all coercion from string
>> to number and from number to string from the language.
>
> String to number, yes. Number to string, no.
>
>> It means you should not be able to do this:
>>
>>     answer = "6" * 7
>
> One can always define metamethods for strings, so I can live with this.
>
>> or this:
>>
>>     print(string.format("the answer is %s", 42))
>>
>
> Actually "%s" allows anything. The Lua equivalent of Python "%r".
>
>> print(string.format("%s",io.stdin))
> file (0xb7719ac0)
>
>

Perhaps "%s" should explicitly mean "invoke tostring on this".

(Maybe it already does :-) )