Originally Posted by Atropos
Thanks to those who replied, but I'm still not clear what the actual gain is from trying to force OOP like this. Can someone provide an example use case where using ZO_Object allows them to do something that would otherwise be a big pain in the ass?
Is it simply a mechanism for making programming LUA more friendly/intuitive for people who are used to other OO languages?
|
Think of it as convenient syntax sugar.
Compare:
Lua Code:
local Bar = {}
function Bar:foo() ... end
local b = setmetatable({}, {__index = Bar})
b:foo()
To:
Lua Code:
local Bar = ZO_Object:Subclass()
function Bar:foo() ... end
local b = Bar:New()
b:foo()
It simply adds descriptive names to Lua constructs. You can see right where Bar is defined that it's a new (sub)class. And that b is an instance of Bar.