Quantcast
WoWInterface - View Single Post - how is better to write ...
View Single Post
03-29-20, 06:54 PM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,936
In general, they're equal, but there is a very niche difference between them, and that's the order of when the function is compiled in memory and when the variable it's assigned to is created. This difference can only be seen when dealing with local functions trying to access their own pointer, usually by recursive calling.


Code:
local function RecursiveFunc()
The local is created before the function is compiled. This function can see the local variable and is capable of calling itself.


Code:
local RecursiveFunc=function()
The function is compiled before the local is created, so this function cannot see itself. Attempts to call recursively will try to look for it in the global environment.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 03-29-20 at 07:08 PM.
  Reply With Quote