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

std: Add a note about the print! macro and output buffering #23826

Merged
merged 1 commit into from
Mar 31, 2015

Conversation

richo
Copy link
Contributor

@richo richo commented Mar 29, 2015

cc #23818

@rust-highfive
Copy link
Collaborator

r? @huonw

(rust_highfive has picked a reviewer for you, use r? to override)

@@ -64,6 +64,9 @@ macro_rules! panic {
///
/// Equivalent to the `println!` macro except that a newline is not printed at
/// the end of the message.
///
/// Note that because stdout is by default unbuffered on unix systems, this may
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be buffered instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Err, yeah. Thanks for the catch!

@tanadeau
Copy link
Contributor

It would be helpful if this had a reference to the flush() method on the Write trait and an example of the use of print! that needs flushing (like a prompt).

@@ -64,6 +64,9 @@ macro_rules! panic {
///
/// Equivalent to the `println!` macro except that a newline is not printed at
/// the end of the message.
///
/// Note that because stdout is by default buffered on unix systems, this may
/// result in output not being emitted until stdout is flushed.
Copy link
Member

Choose a reason for hiding this comment

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

I think this may want to be rephrased to not mention unix and also mention "line buffering" somewhere, perhaps:

Note that stdout is frequently line-buffered by default so it may be necessary to use io::stdout().flush() to ensure the output is emitted immediately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally reasonable, is there markup to make it actually linkify io::stdout ? (Will it do this by default? That would be amazing)

Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately, no, there is no default auto-linking, but you can always do it manually via [foo](../bar/baz.html)

@richo
Copy link
Contributor Author

richo commented Mar 30, 2015

I updated the doc comment. Including the link inline made it no longer possible to just copy the invocation out of the comment, which I felt outweighed the benefit.

@@ -64,6 +64,9 @@ macro_rules! panic {
///
/// Equivalent to the `println!` macro except that a newline is not printed at
/// the end of the message.
///
/// Note that stdout is frequently line-buffered by default so it may be necessary to use
/// io::stdout().flush() to ensure the output is emitted immediately.
Copy link
Member

Choose a reason for hiding this comment

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

Can you match the surrounding style and wrap this to 80-characters as well? Also, can you put io::stdout().flush() in backticks as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, apologies somehow tw got screwed up in my editor.

@alexcrichton
Copy link
Member

@bors: r+ 6e8693b rollup

Thanks!

Manishearth added a commit to Manishearth/rust that referenced this pull request Mar 31, 2015
bors added a commit that referenced this pull request Mar 31, 2015
@bors bors merged commit 6e8693b into rust-lang:master Mar 31, 2015
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.

7 participants