Skip to content

Conversation

@jturner314
Copy link
Member

This PR adds the array, azip, s, and par_azip macros to their respective crates' preludes. Where possible, it also replaces macro_use with normal use statements.

This requires Rust 1.30.

@bluss
Copy link
Member

bluss commented Oct 28, 2018

Oh it's beautiful. And those things now share the same namespace (or maybe equally named things are punned and both used, just like for newtype constructors).

@jturner314
Copy link
Member Author

Yeah, this is so much cleaner than the old #[macro_use] annotations.

Macros have a separate namespace, and all equally named things are imported when used. (For example, use ndarray::stack; imports both the function and the macro.)

@bluss
Copy link
Member

bluss commented Nov 18, 2018

The short macro name of s might now be yet more risky, when it comes through the prelude. I think it will work in practice though.

@jturner314
Copy link
Member Author

I just added another commit that makes it possible to use s! and azip! without importing them. (You can now write ndarray::s![1..2, ..], for example.)

The short macro name of s might now be yet more risky, when it comes through the prelude. I think it will work in practice though.

Yeah, I think it'll be fine because (1) macros are in a separate namespace from variables/functions, (2) a short name like s seems very unusual for a macro, and (3) macros are evaluated at compile time, so potential issues will be caught at compile time.

Also remove `macro_use` of `array`, `azip`, `s`, and `stack`, and
replace with normal `use` statements.
This makes it possible to use `ndarray::s![]` and `ndarray::azip!()`
without importing them with `macro_use` or `use`.
@bluss
Copy link
Member

bluss commented Nov 27, 2018

Towards the future, breaking change season is here

@bluss bluss merged commit 1b1a503 into rust-ndarray:master Nov 27, 2018
@jturner314 jturner314 deleted the macro-use branch November 27, 2018 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants