[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: More lua stack operations support?
- From: William Ahern <william@...>
- Date: Mon, 3 Mar 2014 03:11:54 -0800
On Mon, Mar 03, 2014 at 11:03:23AM +0100, Jean-Luc Jumpertz wrote:
> Le 3 mars 2014 ? 10:17, Dirk Laurie <dirk.laurie@gmail.com> a ?crit :
<snip>
> > Maybe you would be able to convince me if you showed an actual
> > rather than a hypothetical example.
>
> Easy. Just think of a simple C function returning multiple values that are
> not produced contiguously in the stack. You'll need to do stack removals
> (or insertions, both are interchangeable) to have the stack with the
> correct layout before returning.
>
If they're not contiguous, how would a block-based operation help?
And if they're not contiguous, I can't see how one could avoid using a
similar number of calls to either lua_pushvalue or lua_remove.
I feel like the proper solution to this ill-defined problem is better stack
hygiene--remove garbage values as soon as possible and maintain a compact
stack.
Speaking for myself, a more compact stack leads to fewer bugs, because when
I modify code the relative positions of values are less likely to change.
And when they do, it's easier to adjust indices. If I create a mess on the
stack and then wait to clean it up 20 or 50 or 100 lines down, I've already
lost the game.