shBLOCK
MModular
•Created by shBLOCK on 10/26/2023 in #questions
Compile time properties?
Is it possible to make compile-time properties for structs?
Mojo doesn't seems to support @property right now. So the only way to implement custom properties in mojo right now is to use the
__getattr__()
function, which isn't a performant solution.
I want to make some vector classes that support "swizzling" like in GLSL (e.g. Vec3(1,2,3).xz
gives Vec3(1,3)
).
I achieved this in Cython by generating every possible combinations (about 50k lines). But I think with advanced parameterization in mojo, this can potentially be much simpler while keeping maximum performance.
I'm not sure if this is already possible in mojo somehow. I will open an issue on github if this interests many people.10 replies