Main Content

Rules, suggestions, considerations for Lua variable names

Archive - Originally posted on "The Horse's Mouth" - 2008-08-05 18:34:59 - Graham Ellis

Rules for naming variables in Lua ...
* MUST start with a letter or underscore
* which MUST be followed by as many or as few letters, digits, underscores as you like
* Case sensitive (sound bite - "there are 52 letters in the alphabet"
* Variable names must NOT be Lua keywords

Suggestions for naming variables in Lua
* Make variable names from relevant and appropriate words
* Keep variable names shortish but not too short to understand
* Have a CaPiTaLiSaTiOn standard
* Standardise on English or American spelling
* Also standardise on which abbreviations are used

Also consider the following when naming your variables
* Hungarian Notation (first letter gives type)
* In Lua (and in other languages) your variable names should assist your commenting.