lua-users home
lua-l archive

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


On Wed, Mar 5, 2014 at 10:09 AM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> This can be somewhat difficult to do, but not too much more. So, in
>> code where "str .. my_num" is done, then you have to manually add
>> `tostring` to get the intended result.
>
> We changed that a little. Now, only 'tostring' itself adds the ".0". So,
> in concatenation and other coersions, the behavior is like it was in
> 5.2:
>
>> = 3.0
> 3.0
>> = 3 + 0.0
> 3.0
>> 3.0 .. ''
> 3
>> tostring(3.0) .. ''
> 3.0
>
> -- Roberto
>


I think that this is a good idea. There is part of me that wants it
the old way. But, I think it's one of those things were the old way
may have promoted bad practice.

So the new way encourages `("%d"):format(3.0)` (or some home-brew
shortened version of the same), which is more verbose but is also
explicit and that's a good thing.

--Andrew