Skip to main content
GameDev.net gamedev.net
🔒 Locked

"Lua has become stackless" ?

Started by swordfish Oct 31, 2005 at 7:10 AM 0 replies 2.5k views
Original Post
swordfish
swordfish
I was just reading an article over at Gamasutra.com titled Game Scripting in Python, where the author does a brief comparison of Lua and Python. In his comparison, he states how both have changed since he initally made the decision to use Python. He states:
Quote:
Both languages have been improved since we made our decision - Lua has become stackless and Python has acquired generators, which allow some similar functionality. Either language is a safe choice.
I'm wondering what he means by "Lua has become stackless". I've been using Lua for several months now, and if I'm not mistaken, isn't the sole concept of Lua based on a stack? I'm confused. Is there a new version of Lua or something?
http://blog.protonovus.com/
fagiano
fagiano
stackless means that when you make a pure lua function call, the VM doesn't make a real C call internally(so doesn't use the OS stack). This allows the program flow to be interrupted(aka coroutines) without hacking around with the C native stack. With a stackeless approach is also possible to perform certain runtime optimization to allow deep recursion or even recursion unrolling(tailcalls) and avoids risk of stack overflows.

Python on the other hand does a C function call for each python call. In fact it 'only' implements generators that are a light version of coroutines(they only allow to suspend 1 function, no nesting). I personally don't understand the design choice behind python-style calls is simply less flexible. However, I haven't looked into python's VM too deeply, too much code for my taste.

ciao
Alberto
-----------------------------The programming language Squirrelhttp://www.squirrel-lang.org

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.