• Advertisement
Sign in to follow this  

Lua coding conventions

This topic is 3952 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement