-
I am using the library "middleclass" for classes |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
For what it's worth, reading the conversations I thought the same. The docs say interfaces can be used with object libraries but do not demonstrate how. I don't use those libraries personally but I think middleclass is be the most popular (confirmed by this) so it could be nice to have an example using it in the doc. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately the main solution I can think to this is type intersection but that's already been said to not be desirable because of edge cases |
Beta Was this translation helpful? Give feedback.
-
The addition of interfaces does not make the operation of Lua OOP models seamless in Teal, but it aims to alleviate the existing difficulties by allowing for the representation of subtyping relations and for the inheritance of interfaces (but not inheritance of implementations).
I'm wondering if the summary in the changelog has oversold the feature. I believe it does make working with object models better than it was before (when you had to effectively cast everything all the time), but I'm sure the existing libraries will always have some inherently dynamic constructor functions which will still require casting.
I'm reluctant about promoting one class model above others in the docs, but it would be nice to have such examples indeed. Perhaps a community repository?
I'm not sure I understood the question! @Hedwig7s could you post a complete small example of how you're using |
Beta Was this translation helpful? Give feedback.
-
Figured it out can do it like this: local interface InstanceFunctions
a: function(self:Instance, a:string)
end
local record Class is middleclass.Class, InstanceFunctions -- Example middleclass Class type
initialize: function(a:number)
end
local record Instance is middleclass.Instance, InstanceFunctions
b: number
end |
Beta Was this translation helpful? Give feedback.
Figured it out can do it like this: