lua-users home
lua-l archive

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


On Wed, Jun 11, 2014 at 10:50 AM, Levente Kovacs <leventelist@gmail.com> wrote:

> I have one more question. Is that true that I can push only 20
> variables to the stack from C? Does that matter what is the length of the
> variable? So can I push 20 pieces from a 10k long string?

When you call a function, the stack is pre-sized for how many elements
that function might need to make use of on the stack.  I don't know if
this is true, but I think he's saying 20 is the default.  You can
*request* that the reserved size of the stack be made larger, with
lua_checkstack():
http://www.lua.org/manual/5.2/manual.html#lua_checkstack

The stack is virtual, it does not necessarily depend on the size of
the elements that it contains.  When you push a string, be it 2k or
2000k, what you are pushing is a reference to that string -- not the
string itself.