lua-users home
lua-l archive

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


> I noticed in the parser that the code is explictly checking for the
> function name and parenthesis to be on the same line--is this
> intentional?

Yes. In Lua 5.0, you can write code like this:

  (print or write)(x, y, z)

where the function to be called is a parenthesed expression. However,
a chunk like

  a = x
  (print or write)(x, y, z)

actually means "a = x(print or write)(x,y,z)", which is hardly the
intended behavior. To avoid such misuses, Lua forbids the parentheses
in a different line from the function.


> 2) lua_open used to take a stack size argument, and now does not.
> Should I worry about lua overflowing its stack,

You should not worry about Lua overflowing its stack, unless it does
more than 4096 (LUA_MAXCALLS) nested calls.


> and is there a way I can limit the memory usage of each lua_State?

You can set a GC metamethod to called at every GC cycle (you need C code
to do that). This method then can check the memory usage and abort the
script if necessary.

-- Roberto