lua-users home
lua-l archive

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


On Mon, Dec 6, 2010 at 2:39 PM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> >>But then we could ask the very same question about table.concat, which
>> >>also doesn't use tostring...
>> >Why should it?
>> Because it would be convenient. Are there any reasons for tostring()
>> not to be called in these 2 cases?
>
> Robustness? Several errors (e.g., a nil value) will be silently
> supressed by 'tostring'. For '%s' this is not such a problem, as usually
> we see the result, so it is easy to spot bugs. In table.concat, however,
> it may cause some pain for debugging.
>
> -- Roberto
>
>

I'm confused by what you mean here. table.concat(), like all the other
table functions like table.sort() and table.insert(), expects to take
a valid Lua array-table and if you pass it one with nils/holes in, it
usually raises no error and just has undefined results. We are
expected to know and understand this for the other functions, why not
table.concat() too?

-Duncan