lua-users home
lua-l archive

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


on 1/19/07 7:05 PM, Rici Lake at lua@ricilake.net wrote:

> Yes. Either lua_tostring() will change the key into something else,
> which is a problem, or it will return NULL, which might cause your
> writeString() function to segfault.

I have to say that the automatic coercion between strings and numbers in the
Lua API is one of my least favorite features. I had mostly seen it as
unnecessary cruft in the past. This thread points out that it is downright
dangerous.

Could we perhaps see a shift in which the core API did not do the
conversion, but luaL_tostring and luaL_tonumber would do so? Furthermore, it
would be nice if luaL_tostring was essentially the same as invoking tostring
on the value so that it could handle arbitrary objects.

Mark