3 ms·
Is the situation for Rust different than as described here: https://github.com/rust-lang/rfcs/pull/208 https://github.com/rust-lang/rfcs/pull/208 “Currently, a
by xh-dude 5y ago
Is the situation for Rust different than as described here: https://github.com/rust-lang/rfcs/pull/208 https://github.com/rust-lang/rfcs/pull/208
“Currently, attributes and macros/syntax extensions are both conceptually macros: they are user-definable syntactic extensions that transform token trees to token trees.”
FWIW I definitely admit the point about Go compiler directives sort of cheating into this space a bit - I see them used responsibly for the most part but it’s a valid point. (Go’s struct tags OTOH, are an escape hatch I revile…).
- adwn 5y ago> Is the situation for Rust different than as described here: https://github.com/rust-lang/rfcs/pull/208 https://github.com/rust-lang/rfcs/pull/208 In short: yes. The wording in that quote is imprecise: I suspect that by 'attributes', pcwalton was referring to user-definable attributes like #[serde(rename_all = "...")] and to custom derive macros like #[derive(Serializable)]. It is impossible to achieve the effects of the #[repr(C)] attribute using macros or token tree transformations.
- previx 5y agoIf you're asking if macros and attributes are interchangeable terms, no they're not.