> A pythonic C++ that doesn’t smell bad.
Obligatory...try Rust?
But actually, try python with mypy and mypyc. It's still a little experimental, but if you stick to simple constructs it works well, and you can compile straight python to fast, static libraries, without using goofy cython syntax.
If by extending you mean that you want to have a type that includes ALL the functionality of another type, without needing to fill in each method, that's already supported.
In your new struct definition, include the desired base type as a member - without giving it a name. That embeds the unnamed member directly, and your new type automatically gets all the interfaces and their underlying implementations. As a python-person I always found this a somewhat odd mechanism, but from a functionality perspective it satisfies what I have wanted to do.
Guess that's what people mean by composability.
Re:What's New in Python 3.11?
by gunapologist99 on Monday June 27, 2022 @03:10PM
(#31899300)
You should check out Nim. I wish more people would! https://nim-lang.org/
I like Nim, but it's not for someone who likes classes.
Nim supports classes and methods.
It has methods, but doesn't really have classes. And class-oriented programming is unidiomatic in Nim.
Re:What's New in Python 3.11?
by chakkepolja on Monday June 27, 2022 @12:32PM
(#31896956)
I think you can reasonably represent inheritance using struct embedding, and that's quite idiomatic in Go.
Re:What's New in Python 3.11?
by francoispon on Monday June 27, 2022 @06:50AM
(#31892769)
can't you get away with just composing the structs, sure not exactly the same but does a good job still
A pythonic C++ that doesn’t smell bad.
I wish Go had classes. I like those damn things. Extending a Dog from Animal with all the methods and data in one place is nice.