Thread Tools Display Modes
05-08-17, 07:00 AM   #1
Kkthnx
A Cobalt Mageweaver
 
Kkthnx's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2011
Posts: 247
Originally Posted by lightspark View Post
The only reason why I do local _G = getfenv(0) is my paranoia o_O

I've seen addons that do some weird manipulations w/ environments, so _G may end up being something else, and a check like _G == getfenv(0) will return false.

IMHO, if you have no paranoia and don't call global functions from inside OnUpdate and prob OnEvent funcs, only if you register for REALLY spammy events, e.g., CLEU, there's no point in creating upvalues for pretty much anything.

Another reason might be to please one's Lua linter
Lmao @ please one's Lua linter! This is so true and has become a thing for me. I use Atom text editor and https://atom.io/packages/linter-lua-findglobals so I guess I am just so used to pleasing it

Also never thought of the whole _G = getfenv(0) deal. Incoming paranoia?
__________________
Success isn't what you've done compared to others. Success is what you've done compared to what you were made to do.
  Reply With Quote
05-08-17, 07:05 AM   #2
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 341
Originally Posted by Kkthnx View Post
Lmao @ please one's Lua linter! This is so true and has become a thing for me. I use Atom text editor and https://atom.io/packages/linter-lua-findglobals so I guess I am just so used to pleasing it

Also never thought of the whole _G = getfenv(0) deal. Incoming paranoia?
I call it _G-fetish

But in most cases upvalues and/or accessing globals via _G are a personal preference or even a style, people like weird things o_O
__________________
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How could this be written neater?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off