Functions are like sections of code that can be reused. When you write
local doSomethingNice = function() print("Cleaning out the garbage...") end
You’re making a block of code, as thomas6 says, that says "when the computer tells me to doSomethingNice, I’ll print “Cleaning out the garbage…” and be done.
The problem is, you haven’t ever told the computer to do it. You have to call the function for it to run:
doSomethingNice()
The parentheses mean “do this function”. So when you write that, the computer obliges and prints “Cleaning out the garbage…”.
Some functions are called internally by Corona. You never actually call them in your code:
scene.show = function(self, event) print(event.phase) end
In this case, the function seems to run by itself because Corona actually calls it behind the scenes (pun intended, heh heh heh). It doesn’t, however; somewhere back in the depths of the Corona engine code, you’ll find the line (or the equivalent in C => Lua).
scene:show(event)
I recommend that you get very comfortable with Lua (and programming in general) before diving into Corona. Without an understanding of the language Corona is built on, you won’t be very productive with Corona itself. Corona provides a pretty good tutorial on Lua here: http://docs.coronalabs.com/guide/start/introLua/index.html.
Bottom line is, if you don’t call it, it won’t run. So, if a function ends up running, somebody somewhere called it. If you didn’t call it, it must have been Corona. Or maybe some tiny (tiny, tiny, tiny) tapir who lives inside your processor.
[EDIT:] Function notation changed in response to comment from @thomas6.