Agreed. Exporting macros feels like a hack. Importing macros feels like a hack. Global namespaces are a pain.
Macros on the whole feel like a second class citizen of the language. I’m not talking about writing them - I’m perfectly fine about that kind of ugliness – I’m referring to the client side usability. I would steer clear from forcing them on the users of my libraries. ~Brendan On 26 Feb 2014, at 8:39 am, Sean McArthur <[email protected]> wrote: > Rust now has the ability to import macros from other crates, hurray! However, > I'd like to propose adjusting the current way of using them to be more like > importing/exporting other symbols of a crate. > > 1) It's more consistent, makes it easier to find where macros came from. > 2) Current usage brings name collisions. > > > Current example: > > pub mod foo { > // assume other macros as well > #[macro_export] > macro_rules! bar ( ... ) > } > > pub mod baz { > // assume other macros as well > #[macro_export] > macro_rules! bar ( ... ) > } > > mod herp { > // i want bar! from foo, and some other macros from baz > [phase(syntax)] > use super::foo; > [phase(syntax)] > use super::baz; > > pub Derp = bar!(); // which bar? is this an ICE? or logic error? > } > > Proposed example: > > pub mod foo { > pub marco_rules! bar ( ... ); > } > > pub mod baz { > pub marco_rules! bar ( ... ); > pub marco_rules! quux ( ... ); > } > > mod herp { > use super::foo::bar!; > use super::baz::quux!; > // using same name macros, no problem > use baz! = super::baz::bar!; > > pub Derp = bar!(baz!()); > } > _______________________________________________ > Rust-dev mailing list > [email protected] > https://mail.mozilla.org/listinfo/rust-dev _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
