3 ms·
I wish the macro system was more ergonomic, like this: fn %identifier(value:%type) -> %type { BytesMut::from(value) } ie, to look like html templates
by mamcx 8y ago
I wish the macro system was more ergonomic, like this:
fn %identifier(value:%type) -> %type {
BytesMut::from(value)
}
ie, to look like html templates like handlebars or similar.
- steveklabnik 8y agoProcedural macros can have this, in a sense; see this crate: https://crates.io/crates/quote https://crates.io/crates/quote
- baby 8y agoI have a question about that actually, macros in C/C++ are disgusting, why isn't Rust trying to improve it? It's better obviously but it is still not a nice thing to parse.
- steveklabnik 8y agoRust macros are almost nothing like C or C++ macros; they operate on an AST, not on the literal text.
- baby 8y agoI'm talking of the syntax. Why can't I write a macro in more rust-like form for example instead of a very different language
- steveklabnik 8y agoWell, patterns are a very different language than rust; rust has no way to express “one or more of this thing” for example. I wasn’t involved when the syntax was chosen, and that was well before our RFC process, so I don’t have any real, deep explanation for you, sorry!
- mamcx 8y agoIn fact thinking about the same, and because I'm building a toy language, a macro system could look like: https://elixir-lang.org/getting-started/meta/macros.html https://elixir-lang.org/getting-started/meta/macros.html
- deleted 8y ago[deleted]