There's an abstract "class" action.base, that provides methods :act and :is_available and may use :_act and :_is_available. Currently, actions are implemented through Table.extend with action.base as a second argument. This has a few downsides:
- Generally, getmetatable(x) does type checking for x. Actions do not follow that convention.
- Using Table.extend is not fully compatible with LuaLS; :is_available and :act have parameter types, underscore methods do not.
- Action definitions break type definition convention (
local methods = {} stuff)
Proposal:
- Use metatable inheritance:
local methods = setmetatable({}, {__index = parent_mt.__index})
-- or maybe
local methods = Table.inherit(parent.mt)
action.base -> action.mt
- Maybe
Table.inherits_mt(x, mt) -> boolean to check inheritance
That's kind of OOP-ish, but otherwise seems to do the job.
There's an abstract "class" action.base, that provides methods :act and :is_available and may use :_act and :_is_available. Currently, actions are implemented through Table.extend with action.base as a second argument. This has a few downsides:
local methods = {}stuff)Proposal:
action.base->action.mtTable.inherits_mt(x, mt) -> booleanto check inheritanceThat's kind of OOP-ish, but otherwise seems to do the job.