lua-users home
lua-l archive

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


On 31.12.2011 at 13:59 Patrick Rapin wrote:

>> Hmm, no replies so far :/  .... is it because of the old Lua version
>that I'm using?
>
>Maybe it is because people, like me, do not really understand your problem.

Then tell me :-)

>
>> I do not need to pass more than 255 arguments
>> to my functions but I need to pass tables with tons of items and they
>> require more stack space than 250 items.
>
>Tables are handled by reference in Lua. Pushing a table on the stack
>only takes 1 slot from it, no matter how big the table is.

Hmm, right. Then I must have increased the MAXSTACK limit for a different
reason. The problem is that I increased MAXSTACK already 6 months ago
because there was a problem with a script. My memory tells me that I increased
it because of a large table passed to a function but as a table is really
taking just one slot, this can't be the case so maybe I increased it because
I wanted to raise the limit of arguments that can be passed to a function.
The problem is that I don't have the script that had problems with MAXSTACK=250
any more. Thus, I cannot tell any more what was the real problem. All I can
tell is that setting MAXSTACK to 1000 solved the problem.

So the only explanation could be that the script tried to pass more than 250
but less than 256 arguments and that's why MAXSTACK=1000 fixed this
specific case.

Well, never mind, thanks for the explanation. Next time I should investigate
more closely into such issues to see what's really going wrong. But it certainly
wouldn't have happened if there had been a word of warning above the MAXSTACK
definition that mentioned the implications of increasing this value :-) There are
at least two:

1) You can't pass more than 255 arguments to a function even if you raise
MAXSTACK.
2) Fiddling with MAXSTACK will break compatibility with bytecode compiled
with different MAXSTACK settings.
...

Hny,

Andreas