lua-users home
lua-l archive

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


>> [1] 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 impression.
>> [2] What are you trying to do anyway? Create some form of virtual Lua environment?
> I'm trying to make a Forth VM, using varargs as the stack.
>> [3] 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)?

—Tim