Rename println! to print!


#1

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?


#2

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.


#3

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!.


#4

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


#5

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

Oh, and apparently Go too.


#6

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


#7

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.


#8

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


#9

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


#10

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