lua-users home
lua-l archive

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


> a=function()end
> = tostring(a()) --> Error.
> = tostring(select(2)) --> Ditto.

tostring() throws an error when it doesn't receive any argument. Since
it is often called to sanitize a result before concatenation, it could
make sense if it returned "nil", or even the empty string instead.

In most other circumstances, these "lack of value" are converted to
nil, but not here.

A partial solution is to append "or nil" to the argument of every
risky tostring() call, but it would be more elegant if it were handled
at the language level.

-- Pierre-Yves