[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: I wish function execution continued past `return'
- From: Duncan Cross <duncan.cross@...>
- Date: Tue, 16 Mar 2010 16:59:42 +0000
On Tue, Mar 16, 2010 at 4:12 PM, steve donovan
> On Tue, Mar 16, 2010 at 6:02 PM, Duboucher Thomas <email@example.com> wrote:
>> No, but in a stack-based programming style, it can be useful to push
>> step by steps the return values on the stack instead of all-at-once at the
>> end of the execution (eg with a return statement).
> Ah, now I understand the point, and why Majic was talking about the C API.
> But overloading 'return' to mean this is a bad idea, since it has such
> a common meaning.
> And, is adding to a table so very expensive?
> steve d.
Also - despite what the C API might lead you to believe - Lua's VM
actually register-based not stack-based. I might be confused about
what that means, but wouldn't it imply that there is no such stack
available to do this, anyway?
Even if I am wrong about that, I still think it would be a bad idea.
In my opinion it would be disastrous to make any change that
drastically changes the meaning of almost all existing valid Lua code.
I also doubt that the performance/memory gains would even be
noticeable, except in very extreme cases. If you're really that
worried about the overhead of allocating and garbage collecting tables
for some function that gets called very frequently, I'd suggest trying
to find some way to reuse them (e.g. with a pool).