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

Lua coding conventions

Started by Bobby_D Jun 25, 2007 at 2:25 AM 1 replies 1.7k views
Original Post
Bobby_D
Bobby_D
If anyone knows where I can find Lua coding convention online, I'd really appreciate it. The fact that you use negative numbers with regards to where you are, and what your manipulating on the Lua stack, yet switch to positive numbers when you refer to item and manipulations on the C++ side of things through me into weird space for a bit. I'm sure those aren't the only conventions of the language. Any advice on the subject would be really awesome to here. I'll take book titles too if you don't know of a online version. Peace.
Kylotan
Kylotan
That stack thing isn't a 'convention' as such, just the way that it works. It's all documented in the relevant places. A coding convention would be more along the lines of some sort of de facto standard in the way people use the language. The negative numbers are relative to the top of the stack, and positive numbers are the absolute position on the stack. There's no magic; they still refer to exactly the same things. You just have to be aware of how a stack works. Relative addressing of the stack is exactly how it's done in C or C++ when you look at the assembly level.

Besides the Lua reference manual, reading the Programming in Lua book is about all you need, really.
Bobby_D
Bobby_D
Hundred percent, Kylotan:
I'm glad you reminded me of that fact on the negative/positive numbers. Apologizes all around. I just got back into to developing in Lua after a years absenteeism. I ask for any Lua gotchas because I want to make sure I don't learn any poor language habits. Thanks for your time. Peace.

Topic Locked

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

Sign in to reply to this topic.