Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
lua_conventions [2015/02/04 20:24]
dean4devil Lua Hightlighting! \o/
lua_conventions [2016/06/15 06:46]
payonel
Line 9: Line 9:
   * Name variables for what they are, don't include type markers in them, i.e. do not use Hungarian notation.   * Name variables for what they are, don't include type markers in them, i.e. do not use Hungarian notation.
   * Nice to have: sort your requires alphabetically (OCD!)   * Nice to have: sort your requires alphabetically (OCD!)
-  * Only comment if it's something complicated/​non obvious. Keep in mind that comments increase file size, which increases the amount of RAM required to run your program!+  * Only comment if it's something complicated/​non obvious. Keep in mind that comments increase file size, which increases the amount of RAM required to load your program!
   * If you have to validate arguments, use the built-in checkArg method. Homogenous error messages are a good thing! Its usage is checkArg(n, value, type1, ...), where n is the number of the argument, value is the value of the argument and type1 and so on are the allowed types for the argument, as retrieved via type(value). The number is used in the error message like so: "bad argument #n (type1 expected, got type(value))"​. So for example, to require the first argument to be a number you'd do checkArg(1, arg, "​number"​).   * If you have to validate arguments, use the built-in checkArg method. Homogenous error messages are a good thing! Its usage is checkArg(n, value, type1, ...), where n is the number of the argument, value is the value of the argument and type1 and so on are the allowed types for the argument, as retrieved via type(value). The number is used in the error message like so: "bad argument #n (type1 expected, got type(value))"​. So for example, to require the first argument to be a number you'd do checkArg(1, arg, "​number"​).
  
Line 42: Line 42:
 end end
 </​code>​ </​code>​
 +
 +Contents
 +-----------
 +{{page>:​contents&​noheader&​noeditbutton&​nouser&​nofooter}}