what is blocking them though....my question is not about what we have rn but why we have it this way....why not a constexpr function in C++ or const eval function in Rust ....I'm assuming the return type can be a wrapper around something that's known at compile time....since the compiler will plug those bytes in anyways so the compiler knows the size..... what magic does macros have and const eval functions in Rust "cannot" ?
Macros can emit arbitrary code. Functions can only return predefined types with known sizes.
I'm assuming the return type can be a wrapper around something that's known at compile time....since the compiler will plug those bytes in anyways so the compiler knows the size.....
Are you suggesting a const eval function that returns CompilerByteLiteral or something? Because that's what a Rust macro is.
okay let me ask the question in reverse then....can I write a function that invokes this macro as a const eval function that return CompilerByteLiteral if not then why and if yes, then why not writing the function around the compiler built-in directly ?
i suggest you search for compile time reflection. It sounds like what you're asking for. It is proposed for c++, and if you want to test the idea out you can try it in java, it has both compile time and runtime reflection
1
u/bruh_nobody_cares Jul 23 '22
what is blocking them though....my question is not about what we have rn but why we have it this way....why not a constexpr function in C++ or const eval function in Rust ....I'm assuming the return type can be a wrapper around something that's known at compile time....since the compiler will plug those bytes in anyways so the compiler knows the size.....
what magic does macros have and const eval functions in Rust "cannot" ?