-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Stabilize format_args_ln!
#97658
Stabilize format_args_ln!
#97658
Conversation
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
r? @m-ou-se (rust-highfive has picked a reviewer for you, use r? to override) |
Shouldn't it be format_args_ln like the other macros: println, writeln? (arguably even without the underscore) |
This seems awfully specific. Since the stdlib implements formatting macros, can we see a diff of what sort of improvement resulted/would result from using this? |
This came up on Zulip as well. So, I personally think this should keep its current name, but I also don't care strongly and would not block changing it if others feel it should be changed. |
std already uses this in println and writeln, via Currently, if you |
I'm generally against new macros being defined in the stdlib root, and especially so if it's as niche as this one. Can we define it in |
While it may make sense for it to be |
That seems likely to be a persistent source of confusion, since format_args is in the root. |
I've been meaning to finish up the RFC to (re-)export macros from their logical submodules. We're already well north of 50 macros exported from the
Using this approach at every step of the way all Footnotes
|
Rather, it just means that we should be exposing format_args from std::fmt as well. The exposure of macros from the crate root is a legacy technical limitation that we are no longer beholden to, so let's not perpetuate the mistake now that it is no longer required. |
I'm not seeing how this solves the problem? If format_args is exposed from both the crate root and std::fmt, then full consistency would require that this macro also be exposed from both. Otherwise, the set of places they're accessible from would be inconsistent, and could potentially cause confusion. |
39eba2f
to
351a13c
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
76379a7
to
f9c8876
Compare
This comment has been minimized.
This comment has been minimized.
This provides consistency with `writeln!` and `println!` and `eprintln!`.
`format_args_ln!` is generally useful for implementations of formatting macros, and it has clear semantics and a clear interface.
f9c8876
to
ef7c7a1
Compare
I've rewritten this PR to rename |
I am totally fine with But because of https://internals.rust-lang.org/t/null-consistency/16767?u=scottmcm, I was looking at https://www.unicode.org/Public/14.0.0/ucd/NameAliases.txt today:
Where, interestingly, I think consistency with |
@scottmcm That was my original argument as well, but I think consistency with println and writeln is more important. |
I'm not convinced we should stabilize this. I'd prefer if we worked on something like #78356, to make sure that
|
I would love to see further optimizations to format_args, but I don't think that future possibility obsoletes this. This is a simple solution that exists today and that we're already using ourselves, and that other libraries would like to make use of. If we find a more general solution in the future, that wouldn't obsolete this common case any more than it would obsolete writeln or println. |
|
I hope When I write bare metal programs with the core crate, I must implement ( As already commented, we can implement fn print_args(args: fmt::Arguments) {
/* */
}
macro_rules! println {
($fmt:expr) => ($crate::print_args(format_args_nl!($fmt)));
($fmt:expr, $($arg:tt)*) => ($crate::print_args(format_args_nl!($fmt, $($arg)*)));
}
fn main() {
let number = 1;
println!("The number is {number}");
} |
☔ The latest upstream changes (presumably #99451) made this pull request unmergeable. Please resolve the merge conflicts. |
My nod towards consistency is that, if people want to be consistent, then expose both of these from |
I suggest providing the new functionality in syntax of
and maybe and then there is no controversy about its naming and namespace, just stay with I don't think it's a widely used macro, so a little more complex syntax doesn't matter IMO. |
👋 Hello, I'm writing this comment in this stabilization PR to notify you, the authors of this PR, that #100591 has been merged, which implemented a change in how features are stabilized. Your PR has been filed before the change, so will likely require modifications in order to comply with the new rules. I recommend you to:
That's it! The If you have any questions, feel free to drop by the zulip stream, or ping me directly in this PR's thread. Thanks! 👋 |
I would love to revisit this. It seems like there are two categories of concerns here. First, there are the various bikesheddings of what this should be named. I really don't have a strong opinion here, apart from wanting consistency. Second, there's the question of whether to have this at all. On that point, it feels like this is being held to a standard that, for instance, I would argue that even if we have a version of |
I'd like to add a specific +1 to this. When developing in a |
Gotcha, thanks for the pointer Josh! |
#111060 shows that |
format_args_ln!
(formerlyformat_args_nl!
) is generally useful for implementations of formatting macros, and it has clear semantics and a clear interface.