4 ms·
Rust's procedural macros let you write Rust code that generates Rust code. In combination with tools like quote, it's just a much clunkier version of the same t
by lpghatguy 8y ago
Rust's procedural macros let you write Rust code that generates Rust code. In combination with tools like quote, it's just a much clunkier version of the same thing that Terra offers!
- eslaught 8y agoI actually wrote about this here: https://internals.rust-lang.org/t/rust-2019-towards-richer-language-extensions/9151 https://internals.rust-lang.org/t/rust-2019-towards-richer-l... In short, the biggest difference is that Terra makes it very easy to interact with the compiler at every level: I can insert new keywords, and incrementally type check pieces of code to see (a) if they compile and (b) what types they produce. This makes it surprisingly easy to build really powerful tools like Regent [1]. While if you read through the rest of the thread, it does sound like it's possible to do this in Rust, it will be very painful, at least today. In particular, it would require either (a) calling out to rustc as an external program, which would probably be very slow, (b) rebuilding the parts of rustc in the DSL compiler, which realistically isn't going to happen, (c) directly hacking on rustc, which is a lot of work and would result in a hard fork to the language, or (d) radically simplifying the DSL compared to what Rust provides, which I think would be counterproductive. So, without a lot more work I think this is a no-go for the moment. But I'm eager to see if the Rust team can come up with something better, since I like Rust in many other ways and it would be great to see Rust grow a capability like this. [1]: http://regent-lang.org/ http://regent-lang.org/