lua-users home
lua-l archive

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


Evan DeMond wrote:
but should the names of CLUE_IMPORT and CLUE_EXPORT be switched?

I like SET/GET, which is consistent with the naming conventions of the Lua C API. IMPORT/EXPORT reminds me of modules in other languages (but note that "export" is used in the Reference Manual in two different ways.)

BTW, the CLUE functions very roughly correspond to CRUD (create, read, update and delete) functions in data storage. Well...CLUE_DO allows create, update, and delete, but not read, which is supported by CLUE_EXPORT. Usually we delete by setting a variable to nil, but CLUE_IMPORT currently does not support a data type of nil (since lua_pushnil requires only one argument).

> #define CLUE_DO(L, code)                        \
>   luaL_dostring(L, code)

Careful: luaL_dostring expands to a lua_pcall(L, 0, LUA_MULTRET, 0)). The LUA_MULTRET can leave values on the stack. I think you want lua_pcall(L, 0, 0, 0)). On the other hand, it could be useful for CLUE_DO to be able to return values, which for one thing would allow a single function to support all of CRUD.

[1] http://en.wikipedia.org/wiki/Create,_read,_update_and_delete