Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upRFC: add `eprint(ln)!` #1869
Conversation
zackw
referenced this pull request
Jan 23, 2017
Closed
Add `eprint!` and `eprintln!` macros to the prelude. #39229
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I think there should be both I think the final name shouldn't focus too much on the “error” part. Yes, the output stream is called stderr, but it really just means “out-of-band” messages that are not part of the regular output. |
This comment has been minimized.
This comment has been minimized.
comex
commented
Jan 23, 2017
|
However, |
This comment has been minimized.
This comment has been minimized.
ExpHP
commented
Jan 23, 2017
•
|
Adding only for dla_step in 0..NPARTICLE {
err!("Particle {:8} of {:8}: ", dla_step, NPARTICLE);
// ... long, time consuming computation ...
errln!("({:8.6}, {:8.6}, {:8.6}) ({:5?} ms)",
(pos.0).0, (pos.1).0, (pos.2).0, timer.last_ms()
);
}
That said, this kind of usage of stderr also conflicts with its typical designation as "a safe place to dump stuff"; if I added debugging output to methods called during that computation, it would mess up my nice output. In this sense, I would almost see a lack of |
This comment has been minimized.
This comment has been minimized.
|
I'm of the opinion that, whatever we call it, we should add it. I've reimplemented these macros in far too many Rust programs. |
This comment has been minimized.
This comment has been minimized.
|
I would also like to have this. Like @ubsan, I've written this macro a gagillion times. Some lightly held opinions:
|
This comment has been minimized.
This comment has been minimized.
|
Update: Rust should avoid introducing excessively abbreviated names, such |
BurntSushi
self-assigned this
Jan 25, 2017
This comment has been minimized.
This comment has been minimized.
|
On the name bikeshedding: I feel like |
This comment has been minimized.
This comment has been minimized.
|
I would rather see it be There's also a consistency or learning issue. We don't use What does the stdlib use for errors right now? Whatever it is, we should align the name with that. |
This comment has been minimized.
This comment has been minimized.
|
My objection to |
jplatte
reviewed
Jan 25, 2017
|
|
||
| It will, however, be necessary to add text to the reference manual and | ||
| especially to the tutorials explaining the difference between "primary | ||
| output" and "status reports", so that programemrs know _when_ to use |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
jplatte
commented
Jan 25, 2017
•
|
I like @Havvy's suggestion of I think I'm slightly in favor of |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
I dislike this strongly, for this reason: You aren't supposed to use I think |
This comment has been minimized.
This comment has been minimized.
|
@ticki Every command line program I've ever written has never needed to care about the performance of writing to I'm sympathetic to |
This comment has been minimized.
This comment has been minimized.
|
FWIW it might be a better idea to go with the |
This comment has been minimized.
This comment has been minimized.
|
Logging is pretty orthogonal to output designed for consumption by an end user. |
This comment has been minimized.
This comment has been minimized.
|
I can't say my experiences are the same. If you log extensively, you can easily severely slow down the program, whereas using Moreover, I would say that just throwing out some logs into That being said, this macro can be useful for debugging, but even then you rarely need to filter between stderr and stdout when you debug. |
This comment has been minimized.
This comment has been minimized.
|
@ticki It's pretty common for me to use |
This comment has been minimized.
This comment has been minimized.
|
My most common use case for |
This comment has been minimized.
This comment has been minimized.
|
There's nothing hacky about printing an error message to |
This comment has been minimized.
This comment has been minimized.
theduke
commented
Jan 26, 2017
•
|
Please don't call it These would all be better, with my personal (weak) preference towards
|
This comment has been minimized.
This comment has been minimized.
|
Out of all the suggestions, I still prefer one from the internals thread: println!(stderr, "this happened: {}", err);Adding a variant to the macro that can be either |
This comment has been minimized.
This comment has been minimized.
|
At the risk of further bikeshedding: I prefer the forms that start with something other than @seanmonstar That looks appealing, but seems difficult to implement in a robust way. Do you intend |
Kimundi
added
the
T-libs
label
Jan 26, 2017
This comment has been minimized.
This comment has been minimized.
iamcodemaker
commented
Jan 26, 2017
|
Bikeshed: I prefer |
This comment has been minimized.
This comment has been minimized.
dpc
commented
Jan 27, 2017
|
|
This comment has been minimized.
This comment has been minimized.
cristicbz
commented
Mar 12, 2017
|
This comment has been minimized.
This comment has been minimized.
matthieu-m
commented
Mar 12, 2017
|
I fully second @dpc here. No matter the name we'll need to get used to it anyway, so I don't see much point in bikeshedding it to death. Let's just make it obvious that it's about printing to stderr. |
This comment has been minimized.
This comment has been minimized.
k3d3
commented
Mar 12, 2017
|
One vote for |
This comment has been minimized.
This comment has been minimized.
I will make time to do that if no one beats me to it. Where can I find the publication schedule for the book, so I can know when it needs to happen by? |
This comment has been minimized.
This comment has been minimized.
Here let me propose two more bike-shed colors
I am actually skeptical that we cannot use #![feature(use_extern_macros)]
macro_rules! vec {
($a:tt) => { "no I'm not a vec :p" }
}
fn main() {
println!("{:?}", vec!(4));
println!("{:?}", std::vec!(4));
}
// std::vec! is fine, so why not std::error!?BTW, if users of most other languages can live without a dedicated print-to-stderr function, I don't see how we are escalating to a crisis here
|
This comment has been minimized.
This comment has been minimized.
ExpHP
commented
Mar 12, 2017
•
Eh? To me this is the primary motivation! The inability of tests to capture stderr is a massive pain in the behind and leaves me constantly sprinkling around ...yet by that same token, I still ultimately agree with your conclusion. There should be more ways to write capturable output than through a macro; since macros cannot be passed around like files can, and are impossible to abstract over except through more macros. (well, okay, you can do some amount of abstraction with callbacks, but only so much!) To be honest, I'm not sure I understand why rust's |
This comment has been minimized.
This comment has been minimized.
ghost
commented
Mar 12, 2017
And in the discussion in #1561, one concern was about spurring use of the macro import/export system and demonstrating it was understandable and manageable. This seems like a perfect job for that (and I'm a fan of this syntax). |
This comment has been minimized.
This comment has been minimized.
Thank you @zackw! Basically as soon as this stabilizes... we don't have any hard dates yet, it's just "as soon as everything gets done". See all the states the chapters have to go through and which chapter is in which state (be sure to scroll to the right), chapters 2, 3, 4, and 6 are supposed to be pretty much "frozen" right now with only small changes (I hope this to be a small change) since they'll be going through layout soon. |
carols10cents
referenced this pull request
Mar 12, 2017
Closed
Use the new print-to-stderr macro when it's stable #534
This comment has been minimized.
This comment has been minimized.
suhr
commented
Mar 12, 2017
|
I was about to propose |
This comment has been minimized.
This comment has been minimized.
vi
commented
Mar 13, 2017
|
|
This comment has been minimized.
This comment has been minimized.
vi
commented
Mar 13, 2017
|
Can we reuse |
This comment has been minimized.
This comment has been minimized.
|
CAUTION We may create very short name, but only for very useful use cases. Per kennytm's comment above, many other languages don't have short name for this use case (i.e. writing to stderr).
|
This comment has been minimized.
This comment has been minimized.
dpc
commented
Mar 14, 2017
•
|
@liigo A program should print only a direct result to |
This comment has been minimized.
This comment has been minimized.
|
Ok the libs team convened today and we discussed this RFC. Overall there definitely seems to be broad agreement to the functionality of these macros and the question was the name. Of the many many names proposed here we've decided to stick with the original proposal, Thanks again for the RFC @zackw! |
alexcrichton
referenced this pull request
Mar 14, 2017
Closed
Tracking issue for addition of eprint/eprintln macros #40528
This comment has been minimized.
This comment has been minimized.
|
Tracking issue: rust-lang/rust#40528 |
alexcrichton
merged commit c53d19e
into
rust-lang:master
Mar 14, 2017
zackw
referenced this pull request
Apr 10, 2017
Merged
Add `eprint!` and `eprintln!` macros to the prelude. #41192
bors
added a commit
to rust-lang/rust
that referenced
this pull request
May 10, 2017
frewsxcv
added a commit
to frewsxcv/rust
that referenced
this pull request
May 11, 2017
frewsxcv
added a commit
to frewsxcv/rust
that referenced
this pull request
May 11, 2017
This comment has been minimized.
This comment has been minimized.
SRGOM
commented
Jul 21, 2017
•
|
I know this is a done deal but I'd like to very briefly present my thoughts against it- Given that stdin/stdoout/stderr are unix file descriptors, including this in standard rust library with very specific use is not a "rustic" way of handling things. I personally think the right way would be that we have multiple streams: Out, trace, debug, warn, error and at the start of a program the runtime initializes (or user manually) each based on what file descriptors are provided by the OS/shell. So on windows console, where only one stream is available, all these would go to I'm not trying to start a flame war and I'm typing this on Unix myself but let's face it, these streams were designed when there was no GUI. The reason rust works is because rust has thrown out all "conventional" wisdom and starts with 0 baggage. I think a 0 baggage here would be having an option to have multiple streams. I haven't given too many details/some inconsistent details but I can flesh out more in the off chance you guys might be interested in thinking about it. |
This comment has been minimized.
This comment has been minimized.
dpc
commented
Jul 21, 2017
|
@SRGOM: I've seen this in Powershell, and I dislike it. It really complicates things, for no good reason. |
zackw commentedJan 23, 2017
Continuing discussion from https://internals.rust-lang.org/t/extremely-pre-rfc-eprintln/4635/7 and rust-lang/rust#39229.