Differences between class and struct
I know classes aren't implemented yet and structs aren't complete, but do we have a sense what they are going to look like when they're done and what their differences will be? I have a few specific questions:
1. Will classes be a high-level pythonic version of structs (like
def
is to fn
) or will classes have low-level performance?
2. I know structs will eventually work with traits and will probably be able to use extensions in a way similar to inheritance. Will classes work with traits or will they have to inherit from other classes?
3. Given that Mojo is aiming for python compatibility, I imagine classes are going to have to support multiple inheritance. Since it can be a pretty controversial feature, will structs support anything like multiple inheritance through multiple extensions?2 Replies
I think it would be similar to how Swift does it: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/classesandstructures/
GitHub
Mojo and Dynamism · modularml mojo · Discussion #466
Mojo has the lofty goal of being a simple, powerful, and easy-to-use language like Python but with features that allow programmers to reach the performance of C. One of Mojo's approaches is to ...