|
|
|
|
|
by ameliaquining
3 days ago
|
|
Yes, a Rust procedural macro is a function that takes a Rust syntax tree as an argument and returns a Rust syntax tree. When you use it, the compiler compiles it (for the host architecture), dynamically loads it into the compiler process, calls it, and inserts the output into the code to be compiled. https://doc.rust-lang.org/book/ch20-05-macros.html#procedura... I don't see why this would inhibit optimization, unless you mean it slows down compilation, in which case, yep, that's a real and rather notorious downside. |
|
That's actually amazing. So the compiler's own data structures are visible in the language.
I see how it works now. Thanks for explaining.