Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add eprint! and eprintln! macros to the prelude. #39229

Closed
wants to merge 1 commit into from

Conversation

zackw
Copy link
Contributor

@zackw zackw commented Jan 21, 2017

These are exactly the same as print! and println! except that they write to stderr instead of stdout. See issue #39228 and/or https://internals.rust-lang.org/t/extremely-pre-rfc-eprintln/4635 for further discussion. Currently gated on #![feature(eprint)] but I hope they can be stabilized in time for 1.16.

I have not checked through the documentation for places where these should be used / recommended in place of print(ln)!.

These are exactly the same as `print!` and `println!` except that
they write to stderr instead of stdout.  Issue rust-lang#39228.
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@steveklabnik
Copy link
Member

Adding a new macro requires an RFC, since macros are global and insta-stable. See rust-lang/rfcs#1653 for a recent RFC that was like this. Could you do that please? Thanks!

@steveklabnik
Copy link
Member

(We can always re-open this PR if the RFC goes through, as well.)

@steveklabnik
Copy link
Member

(On a personal note; I've always felt like this was missing, and agree with the other comments that I'm broadly in favor)

@zackw
Copy link
Contributor Author

zackw commented Jan 22, 2017

Adding a new macro requires an RFC. Could you do that please?

Can do, but possibly not for a couple days.

@zackw
Copy link
Contributor Author

zackw commented Jan 23, 2017

RFC posted here.

Copy link
Contributor

@nodakai nodakai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we can just revive this PR, right?

reason = "implementation detail which may disappear or be replaced at any time",
issue = "0")]
#[doc(hidden)]
pub fn _eprint(args: fmt::Arguments) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to merge this with _print()?

///
/// Panics if writing to `io::stderr()` fails.
#[macro_export]
#[unstable(feature = "eprint", issue="39228")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue #40528

@zackw
Copy link
Contributor Author

zackw commented Apr 10, 2017

Now we can just revive this PR, right?

I mean to (well, to open a new one, apparently that's better for bors) but I got bogged down in revising The Book to match, plus a lot of other work. Real Soon Now™.

frewsxcv added a commit to frewsxcv/rust that referenced this pull request May 11, 2017
Add `eprint!` and `eprintln!` macros to the prelude.

These are exactly the same as `print!` and `println!` except that they write to stderr instead of stdout.  Issues rust-lang#39228 and rust-lang#40528; previous PR rust-lang#39229; accepted RFC rust-lang/rfcs#1869; proposed revision to The Book rust-lang/book#615.

I have _not_ revised this any since the original submission; I will do that later this week.  I wanted to get this PR in place since it's been quite a while since the RFC was merged.

Known outstanding review comments:

* [x] @steveklabnik requested a new chapter for the unstable version of The Book -- please see if the proposed revisions to the second edition cover it.
* [x] @nodakai asked if it were possible to merge the internal methods `_print` and `_eprint` - not completely, since they both refer to different internal globals which we don't want to expose, but I will see if some duplication can be factored out.

Please let me know if I missed anything.
frewsxcv added a commit to frewsxcv/rust that referenced this pull request May 11, 2017
Add `eprint!` and `eprintln!` macros to the prelude.

These are exactly the same as `print!` and `println!` except that they write to stderr instead of stdout.  Issues rust-lang#39228 and rust-lang#40528; previous PR rust-lang#39229; accepted RFC rust-lang/rfcs#1869; proposed revision to The Book rust-lang/book#615.

I have _not_ revised this any since the original submission; I will do that later this week.  I wanted to get this PR in place since it's been quite a while since the RFC was merged.

Known outstanding review comments:

* [x] @steveklabnik requested a new chapter for the unstable version of The Book -- please see if the proposed revisions to the second edition cover it.
* [x] @nodakai asked if it were possible to merge the internal methods `_print` and `_eprint` - not completely, since they both refer to different internal globals which we don't want to expose, but I will see if some duplication can be factored out.

Please let me know if I missed anything.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants