I sometimes see people localizing globals, however I do not understand why they do this.
Example:
local setmetatable = setmetatable
local table = table
Why do people do this? I’ve searched around, however I am unable to find anything.
I sometimes see people localizing globals, however I do not understand why they do this.
Example:
local setmetatable = setmetatable
local table = table
Why do people do this? I’ve searched around, however I am unable to find anything.
You can for example override the global function print
.
local old_print = print
print = function(...)
old_print("message: ", ...)
end
print("test") --> message: test
I’m not sure about this but from what i know is for the same reason they localise CFrame.new or math.min to optimize their games. Theres propably another reason but thats what i believe
Some globals are imported which makes that process unnecessary (really wish boblox wasn’t vauge about it tho)
Edit: sauce Performance - Luau
As far as I know, Roblox has made it unnecessary to localize built-in globals by performing the optimization for you under-the-hood.