[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: table.unpack question.
- From: Dirk Laurie <dirk.laurie@...>
- Date: Sat, 25 May 2013 06:42:41 +0200
2013/5/25 Pierre-Yves Gérardy <pygy79@gmail.com>:
> Lua 5.2 lifts this limit for `table.unpack()`, but the maximum size
> varies according to the circumstance.
> In my test case, it works up to 999970 in the REPL, and 999977
> from a script.
> Is there a any guaranteed safe size?
LUAI_MAXSTACK (see `luaconf.h`) less what you are already using.
Which depends.
It would be easy to do in C. The critical information is hidden from the
API, you only have `checkstack`. But even with that you could extract
the information by a bargaining process as the `#` function does.
You: What's the largest safe stack size?
Lua: How much do you want?
You: 1000000.
Lua: Sorry, you can't.
You: 1000000-32.
Lua: That's OK.
You: And what about 1000000-16?
etc.
The Lua designers encourage you to customize it. In `luaconf.h`:
@@ LUAI_MAXSTACK limits the size of the Lua stack.
** CHANGE it if you need a different limit. This limit is arbitrary;
** its only purpose is to stop Lua to consume unlimited stack
** space (and to reserve some numbers for pseudo-indices).
*/
So if you have a shiny new machine with lots of main main memory and your
window manager and browser is not hogging it all, you can probably hoick
it up by a factor of 50. Of course, Lua will do the hogging then :-)