I think it would be better to declare the default implementations of aspect functions in the classes implementing the aspects instead of the aspect interfaces. The concern with default functions was reusability, but having them implicitly copied from the interface could be confusing. Instead of having the default functions implicitly copied, writing this code would at least make it clearer where they came from:
local ICharaSandBag = require("mod.elona.api.aspect.ICharaSandBag")
local CharaSandBagAspect = require("mod.elona.api.aspect.CharaSandBagAspect")
local MySandBag = class.class("MySandBag", ICharaSandBag)
function MySandBag:init()
-- ...
end
-- Proposed change: document the aspect method reuse explicitly
MySandBag.hang_on_sand_bag = CharaSandBagAspect.hang_on_sand_bag
MySandBag.release_from_sand_bag = CharaSandBagAspect.release_from_sand_bag
Because interface methods have always been copied from the start, this is a only change in convention instead of a change in the way the OOP system works.
I think it would be better to declare the default implementations of aspect functions in the classes implementing the aspects instead of the aspect interfaces. The concern with default functions was reusability, but having them implicitly copied from the interface could be confusing. Instead of having the default functions implicitly copied, writing this code would at least make it clearer where they came from:
Because interface methods have always been copied from the start, this is a only change in convention instead of a change in the way the OOP system works.