Open martinvuyk opened 2 weeks ago
Would be a very nice workaround. Also helps with length of Tuple
.
I think I'd rather move metaprogramming in the direction of Zig's comptime. For instance, Foo.__member_vars
Foo.__traits
and Foo.__member_functions
. Zig has one of the most battle tested reflection systems out of the languages I know of, and @parameter already gives us a lot of the tools it would need. I think that if we leave the "normal" metaprogramming to the current system and then only have something like this for a reflection API, we'll be in a better place. I think that Type will probably have to be a compiler builtin anyway, especially if we want to allow modifying/copying the type (which we do for things generating like SoA and AoSoA).
Review Mojo's priorities
What is your request?
Several requests to make this possible:
@uses_arguments_statically
functions which take in arguments but internally do compile time known operations.__type__() -> AnyType
: dunder that gets added by codegen when on argument type signatures__trait__() -> AnyTrait
: dunder that gets added by codegen when on parameter type signatures_implements[type, trait]()
andrebind_trait[type, trait]()
as asked for in #3630__trait_of()
that returns the whole type's method signatures as a trait as asked for in #3047.What is your motivation for this change?
More pythonic code when writing generics. And overall a better experience. This will potentially become the compile time version of
Variant
Any other details?
This potentially helps by indirectly solving/being a workaround for
3403
3272
3252
3148
Sidenote: we might also want to add the ability for types to control how to be implicitly cast between mutable and immutable references. This will make generic code for non owning types much better (or even enabling Read Write locks to be embedded into the type system in an awesome way).