Re: [rust-dev] RFC: Importing/exporting macros

2014-02-25 Thread Brendan Zabarauskas
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  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
> Rust-dev@mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev

___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev


Re: [rust-dev] RFC: Importing/exporting macros

2014-02-25 Thread Corey Richardson
This is problematic because name resolutions happens far after macro
expansion. I think this could be doable with an extremely limited
"macro module system", but I think it's not-very-good to have the same
path syntax for two incredibly different systems.

On Tue, Feb 25, 2014 at 4:39 PM, Sean McArthur  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
> Rust-dev@mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>
___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev


[rust-dev] RFC: Importing/exporting macros

2014-02-25 Thread Sean McArthur
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
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev