For now, mojo’s Any (AnyType) doesn’t work as a standalone declaration inside functions and etc, it requires a static.
Would be cool to see something similar (or better) to C++'s auto data type)
In C++, auto
means “figure it out for me at compile time”, it isn’t a data type. Mojo already has type inference like this for some places (variable declarations), but auto as a function return value is a bit of a footgun.
There is also the concept of trait objects, which gives you the ability to store a vtable and an object pointer so you can implement a form of polymorphism, is something that we are going to get and you can hand-write now if you really want to.
1 Like