You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This won't work as in classic, because hump does not really do inheritance. Instead, class:include(other)copies entries from other. So class:is(other) would have to check the meta table and if it does not match it would have to check whether all entries of other are also in class and (have the same type). I imagine this can be quite expensive.
I am also not a fan of such a method, because it encourages bad code:tm:. In most cases you should rely on polymorphism instead. If you really, really need to, you can use duck typing instead. Though really, one should try to use composition over inheritance.
@vrld Sorry for late response and thanks for your answer. Your answer makes sense.
With regards to hump.class, I decided to use a different approach now, a little bit based on ECS. I have an entity and at can include various components which will be added to an array inside the class. This way, I can check types of components in a clean way (using getmetatable check).
A bit like classic, which includes a
instance:is(T)
method.The implementation in classic is as follows:
It's probably possible to do the same here (will check soon and make PR if possible).
Source: https://github.com/rxi/classic/blob/master/classic.lua
The text was updated successfully, but these errors were encountered: