Looking at the basic example for using LibStub (
http://www.wowace.com/addons/libstub/#w_basic-example), I've encountered a return statement that I don't quite understand, as it is outside of any function.
Lua Code:
local lib = LibStub:NewLibrary("MyLibrary-1.0", 1)
if not lib then
return --HERE, NOTICE ME
end
This leads me to think that addons are run as functions, and this return statement will terminate the addon.
I wrote a little test to confirm this theory:
load order: file1, file2
file1:
Lua Code:
print("zero")
--Removing this if statement causes something called a Tail Call (this is new to me as well), which will result in "zero" and "one" getting output, but not file2.
if 1 == 1 then
return
end
print("one")
file2:
After running this code, only "zero" gets output, confirming my suspicion.
However, I'm not sure if my suspicion covers everything here and the addon simply gets terminated, or there are implications for using this that I don't understand. I would appreciate if anyone could elaborate, since my googling haven't been helpful.