Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple inheritance #123

Open
dtroitskiy opened this issue Apr 22, 2023 · 5 comments
Open

Multiple inheritance #123

dtroitskiy opened this issue Apr 22, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@dtroitskiy
Copy link

Hey @kunitoki, as you replied this to me in extensible classes issue

No, there is no multiple inheritance support for binded c++ classes in luabridge, but definately this is something that could be added with minimal effort.

Can you please do it?
I assume deriveClass() should then accept several classes as base instead of one.

@kunitoki
Copy link
Owner

Which order should we resolve the methods / properties ? DFS or BFS ? As we will have runtime dispatching, there might be multiple base classes containing same methods (virtual or non virtual). In c++ non virtual methods are resolved as ambiguous at compile time, but simulating the same in luabridge is costly (we need to resolve the full inheritance tree and reason about ambiguities). Virtual methods should work, but virtual multiple inheritance might open up several cans of works.

Also, traversing the inheritance tree is nearly a linear operation with single inheritance, but can become costly as we add multiple base classes and each base class could have other multiple base classes.

@kunitoki kunitoki added the enhancement New feature or request label Apr 23, 2023
@dtroitskiy
Copy link
Author

Sorry for delayed reply. Honestly, I had to google about DFS / BFS, because wasn't familiar with abbreviations, although I quickly understood what it means, as I use A* algorithm in my project, which is an example of BFS.
But I can't have strong opinion here since I lack any expertise in this kind of things. Intuitively it seems to me that BFS is more corect approach, although it's said it's more costly.
About virtual methods, for me personally it's no problem to make methods virtual wherever it's needed, but I may not see the whole picture of the problem here.
About traversing, maybe some limitations should be introduced, like a setting in LuaBridge to limit traversing iterations or something.

Personally for me the case is really simple: I just want to have one class inherit from a 2-3 bases classes, all of which provide independent functionality, so I'm definitely not going to have any complex resolutions. Because what I have to do now is put one of class on top of inheritance chain, then inherit (completely unnecessarily) another class from it, then another one and so on.
But I understand you need to implement a solution that is capable of working with more complex scenarios. But I'm afraid I don't have some good advices here about better implementations.

@kunitoki
Copy link
Owner

kunitoki commented May 3, 2023

I started working on this and it's a bit more complex than i initially thought, will need a bit more time to get it working properly.

@dtroitskiy
Copy link
Author

Hey @kunitoki, how is the progress on this isssue?
Not urgent for me, but would be nice to have, if still possible.

@kunitoki
Copy link
Owner

kunitoki commented Jun 2, 2023

I had to park it for a while until i have the time to resume it. It will come this summer for sure !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants