lua-users home
lua-l archive

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

Roberto Ierusalimschy wrote:
The drawback is that everyone using Lua would have to start it with
something like


You could always call lua_open(NULL), which isn't so bad.

> If we call it before lua_open, where would we store such value?
> (Lua uses no global/static variables. Everything in Lua is stored
> in a lua_State, which is created by lua_open.)

Well, I guess I could argue semantics and say that you're
using global variables to store the memory and file I/O
function pointers. Allowing us an API to change those
variables just makes Lua more flexible.

> What about varargs, with name-value pairs?
>  lua_open("realloc", &my_realloc, NULL)

Ugh. How about a structure:

  struct {
    lua_ReallocFunc realloc;
    lua_FreeFunc    free;
  } lua_Callbacks;

  lua_open(lua_Callbacks* callbacks);

...where 'callbacks' can be NULL?

As for file I/O, printing, etc.: if I can override these things
without touching the Lua code, great. But again, considering the
intent of Lua is to embed it into a larger application, the
process for overriding these things should be explained clearly
in the manual. I shouldn't have to hunt around the source code
looking for stdc calls, as I have for past versions.

Okay, I'm probably overdue to say that Lua is awesome, and
despite all my complaining I will probably include it in every
project I write. My thanks to the authors for their time and
effort, and for listening to people like me.