News for hackers. Stuff that matters.
Re:Embedding LuaJIT in 30 minutes by aDevilInMe on Thursday August 13, 2015 @06:06PM (#10057510)
The author informs that the stack is "difficult bit to wrap your head around first", then makes a bizarre statement "Once again – pushed values are indexed with negative, function arguments with positive numbers." This is not correct, you can use positive or negative indexes in either case. Positive indexes are absolute and negative are relative to the top of the stack.
Re:Embedding LuaJIT in 30 minutes by vavrusa on Friday August 14, 2015 @02:06AM (#10058849)
Yes you're right, I just hoped that this may be a useful mnemonic (admittedly maybe a confusing one, but worked for me) for people starting with Lua. A simplification. How the index with negative offset is computed is explained in detail in the linked PIL/"The Stack" then. From my experience, the most common errors for beginners are 1-based indexing and stack manipulation.