[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Varargs efficiency
- From: Hisham <h@...>
- Date: Sat, 18 Apr 2015 14:45:31 -0300
On 18 April 2015 at 14:02, Soni L. <email@example.com> wrote:
> On 18/04/15 01:50 PM, Tim Hill wrote:
>>>>  From all the posts you make here, I get the impression you would do
>>>> far better programming in Lisp than in Lua (or any other non-Lisp language).
>>>> Every crazy thing you want to do is possible in Lisp. But that's just my
>>>>  What are you trying to do anyway? Create some form of virtual Lua
>>> I'm trying to make a Forth VM, using varargs as the stack.
>>>>  I don't use it often. I just checked my own codebase at work, and
>>>> out of 18,204 lines of Lua, only 17 uses of varargs, and only 4 of those do
>>>> not deal with logging of some sort (calling either print(...) or
>>>> f:write(...) or some variation on that).
>> You should realize that the caller of a vararg function has no idea that
>> the target function is vararg; it just pushes its arguments onto the Lua
>> stack normally. Thus the resulting data structure is just a continuous block
>> of Lua stack slots which, as Dirk noted, can be accessed in an array-like
>> manner (since the Lua stack is indexable).
>> I would doubt that using varargs as a Forth stack is the best approach.
>> What’s wrong with a Lua array (aka table)?
> Lua arrays can't do nil, Lua stacks can.
If you're already writing a VM to a different language, you can just
map your Forth's nil to a non-nil Lua singleton.