Is there any method or funtion that could danamically resize the size of Lua's stack?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Is there any method or funtion that could danamically resize the size of Lua's stack?

孙世龙 sunshilong
Hi, list

As per the book named as 《Programming in Lua》,which said that[emphasise mine]:
A nice idiom is {string.byte(s, 1, -1)}, which creates a list with the
codes of all characters in s. (This idiom only works for strings somewhat
shorter than 1 MB. **Lua limits its stack size**, which in turn limits the
maximum number of returns from a function. The default stack limit is
one million entries.

Then, a question raises.
Is there any method or funtion that could danamically resize the size
of Lua's stack?

Best regards
Sunshilong
Reply | Threaded
Open this post in threaded view
|

Re: Is there any method or funtion that could danamically resize the size of Lua's stack?

Roberto Ierusalimschy
> As per the book named as 《Programming in Lua》,which said that[emphasise mine]:
> A nice idiom is {string.byte(s, 1, -1)}, which creates a list with the
> codes of all characters in s. (This idiom only works for strings somewhat
> shorter than 1 MB. **Lua limits its stack size**, which in turn limits the
> maximum number of returns from a function. The default stack limit is
> one million entries.
>
> Then, a question raises.
> Is there any method or funtion that could danamically resize the size
> of Lua's stack?

Lua automatically resizes the stack when needed. The limit mentioned
in the book is a hard limit, to avoid a faulty recursive function
consuming all available memory.

-- Roberto