[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Arithmetic on strings
- From: Patrick Donnelly <batrick@...>
- Date: Mon, 9 Jul 2012 00:26:07 -0400
On Mon, Jul 9, 2012 at 12:10 AM, Rena <hyperhacker@gmail.com> wrote:
> +1, I've expressed a few times that functions expecting strings as input
> should call [__]tostring. It'd make life easier when dealing with objects
> that may or may not be strings but can be converted to them. The C API is
> where this bugs me most, as few libraries bother to do it themselves.
Lua 5.2 is better about this. Lua tostring() is simply a wrapper
around luaL_tostring. [The auxiliary library is appropriate for this
coercion I think.] So if a C library wants to coerce an input into a
string, luaL_tostring is basically what you want. No need to
lua_getglobal(L, "tostring").
--
- Patrick Donnelly