[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Is there a C API equivalent to the new # operator for tables?
- From: "Jose Luis Hidalgo" <joseluis.hidalgo@...>
- Date: Thu, 16 Nov 2006 23:29:05 +0100
Of course it can exists, but... The code will be similar to the one I
posted, look that you need to call a function, What if that function
call fails? What if the "__len" is a pice of code tha does something
invalid? IMHO calls like lua_getobjlen are supposed to not fail...
Its very easy to generalize the function to call whatever other
metamethod, I'd rather lua API as it is, simple, small and very easy
to extend... I don't see any necessity of making more complex the lua
API for such easy-to-implement-by-my-own calls... just an opinion :)
On 11/16/06, Jerome Vuarand <email@example.com> wrote:
That's the kind of C code I'd like to avoid, since it emulate code
already present in Lua core. It's redundant to implement it that way,
and redundancy is not a good thing when it's not a feature. I just
noticed the length operator is not the only one which is not exposed by
Lua API. It would be nice to have all operators accessible as C
functions, to ensure consistency between Lua code and C equivalent using
API. In the meantime I'll probably use some "function(obj) return #obj
end" Lua snippets encoded in my C files.
Jose L. Hidalgo Valiño (PpluX)
---- http://www.pplux.com ----