I have a problem with the behaviour of ZO_Object's two methods. It's confusing at best for me. Currently I'm under the impression that it's simply copied from
Programming in Lua.
ZO_Object:Subclass returns
setmetatable({}, {__index = BaseClass}). The returned empty table cannot be used as a metatable itself... yet.
ZO_Object:New returns
setmetatable({}, Class), and adds
Class.__index = Class, so from now on the Class can be used as a metatable. Why does New, method that creates an instance, modify the class? Is there a reason to have a subclass incomplete until an instance is created?
And if you're interested what led me to this question, I want to replace the class (metatable) of an existing object with a subclass (instead of overriding several methods one by one). I never call New on the subclass, so I have to add __index myself due to the current design. It's simple, but I just can't grasp the concept why ZO_Object:Subclass() doesn't return a ready-to-use thing.