lua-users home
lua-l archive

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


>I toyed with the idea, but discarded it as it needs still more
>normalization and possibly ordering of the parameters
Could you please explain that in more detail?

On Sat, Jan 23, 2021 at 12:58 AM Francisco Olarte
<folarte@peoplecall.com> wrote:
>
> Andrew:
>
> On Fri, Jan 22, 2021 at 12:06 PM Andrew Gierth
> <andrew@tao11.riddles.org.uk> wrote:
>
> > If you're not tied to lua 5.1, you could simplify that:
>
> AAMOF my (production) code is tied to 5.3+, but I was translating the
> straight forward push i, push j , pop i, pop j and forgot the API has
> lua_copy, which in fact I've used sometimes, and can do push i, i=j,
> pop j translating my ususal C-one liner "int t=i; i=j; j=t;"
>
> > (The stack check could also be omitted and made the responsibility of
> > the caller)
>
> Yep, I'm not sure what is the usual policy, but I tend to code my aux
> funcs assuming the caller has checked for enough space for what I'm
> returning, and as I return nothing there I checked it.
>
> > In 5.3 or later you can do it without needing an extra stack slot,
> > though this is probably less efficient (needs 4 rotates).
>
> I toyed with the idea, but discarded it as it needs still more
> normalization and possibly ordering of the parameters, besides the
> potentially huge impact of rotations. A native swap, even if limited
> to stack entries, would be a nice addition, as I've found myself
> rotating the top entries many times, and a swap seems to be easy to
> do.
>
> Francisco Olarte.