User:Ganaram inukshuk/Provisional style guide for Lua: Difference between revisions

Ganaram inukshuk (talk | contribs)
Tags: Manual revert Visual edit
Ganaram inukshuk (talk | contribs)
Line 133: Line 133:


=== Use of nested functions ===
=== Use of nested functions ===
Recommended, but may be disregarded for testing. Functions in a function have access to all local variables declared before it, so an equivalent nested function may require fewer parameters.<syntaxhighlight lang="lua">
Recommended for functions whose helper functions only serve that function, but may be disregarded for testing. Nested functions have access to the variables and parameters of the outer function, so an equivalent nested function may require fewer parameters.<syntaxhighlight lang="lua">
function some_function(args)
function some_function(args)
     -- Get args here
     -- Get args here
Line 140: Line 140:
      
      
     -- Helper function
     -- Helper function
     local helper_function(some_value)
     function helper_function(some_value)


     end
     end