Rename println! to print!

I feel that println! should be renamed to print!, and current print! given some other name (print_nnl: no newline?). println! is a bit too long for such a commonly-used macro. I imagine we can’t simply add a flag, as in print("string", end="") of Python?

I feel like it would confuse people coming from non python backgrounds. Our current system makes it clear what is happening.

I’m not in favor of doing end= like in python because that might make some newcomers think we have keyword arguments.

While I’m not a particular fan of this exact idea (renaming println! to print! or Python’s end=""), it does occur to me that println! sounds like a misnomer: it doesn’t “print a line”, as it could print a multi-line string. Instead, it “prints a string plus a newline”. I can’t think of any good alternative naming, off the top of my head. It probably isn’t worth bikeshedding, as there are plenty of people coming in from Java and other languages which already use the println convention.

Aside: if one is heavily using println! to print things out in their code, in many cases they could use the log crate for more informative logging, anyway: log!, debug!, info!, warn!, and error!.

1 Like

println has been used in Pascal, so there’s precedent for that name.

1 Like

It also is used in Java, which is much more popular than Pascal :slight_smile:

Oh, and apparently Go too.

3 Likes

Just in case: note that end='\n' by default in Python.

Yes I know, but it doesn’t change the fact that Rust code does not have keyword arguments, so having one macro that uses some bastardized version of them, while everything else does not would be much stranger than anything gained from this proposal.

1 Like

If you use a lot println sounds like you might consider more advanced logging/formatting (e.g. color escapes and log classes).

-1, the current format is more conventional and less confusing IMO.

-1. println makes it clear what is going on.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.