Hacker News new | ask | show | jobs
by mafribe 4032 days ago
This is a great idea. I wish other compilers would offer this feature (scalac is in dire need of such an option).

Does the Rust macro system require compile-time compilation before type-checking?

1 comments

Not really. Macro expansion occurs during its own phase of compilation (which, in my experience, is generally really fast).
Macro expansion can lead to programs that don't typecheck, unless a very restrictive typing system is used (e.g. MetaML, MetaOcaml). I don't think Rust has such restrictions, therefore I assume that type-checking happens after macro expansion.
It does, but what I was getting at was that full compilation doesn't need to occur first. Macro expansion is one of the very first phases of compilation (and doesn't have access to typechecking information, incidentally).
So Rust macros don't offer full compile-time meta-programming?
Not in Rust 1.0. In the nightlies there are syntax extensions available that give you more power, but those are likely to see significant revisions before they're available in a stable version since they're a major backwards compatibility hazard.
Who's working on this? I may have something to contribute in this direction.