I was perusing an Lua code file, and the very top of the file contains:
1 | TradeSkillFrameReset = TradeSkillFrame_LoadUI; 2 | 3 | TradeSkillFrame_LoadUI = function() 4 | TradeSkillFrameReset(); ... 112| TradeSkillFrame_LoadUI = TradeSkillFrameReset; ... 114| end;
The very first line they are doing an assignment:
TradeSkillFrameReset = TradeSkillFrame_LoadUI;
At this point in the code file they are assigning an undeclaraed identifier (TradeSkillFrame_LoadUI
) to an undeclared variable (TradeSkillFrameReset
). Is this allowed in Lua?
- is variable declaration implicit?
- are all undeclared identifiers assumed to be forward declarations?
The more confusing thing is that the first TradeSkillFrame_LoadUI
seems to do is call itself:
TradeSkillFrame_LoadUI = function()
TradeSkillFrameReset();
How is this not an infinite loop?
Edit: Added remaining references to TradeSkillFrameReset
and TradeSkillFrame_LoadUI
.