fmt: Why Golang doesn't have fmt.Printlnf?

845 views
Skip to first unread message

高橋誠二

unread,
Feb 7, 2017, 8:58:55 PM2/7/17
to golang-nuts
fmt package have no *lnf method, but in other langs,
sometimes it implements Printlnf.
Is there any reason?

dja...@gmail.com

unread,
Feb 7, 2017, 10:31:00 PM2/7/17
to golang-nuts
fmt.Printlnf(f,...) = fmt.Printf(f+"\n", ...)
Djadala 

高橋誠二

unread,
Feb 7, 2017, 10:32:29 PM2/7/17
to golang-nuts, dja...@gmail.com
yes, I know but other languages support it as default, isn't it?

2017年2月8日水曜日 12時31分00秒 UTC+9 dja...@gmail.com:

Nathan Fisher

unread,
Feb 8, 2017, 1:27:09 AM2/8/17
to 高橋誠二, golang-nuts, dja...@gmail.com
I would speculate it's a conscious tradeoff to keep the function count low given it's an equivalent number of characters.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
- from my thumbs to your eyes

Justin Israel

unread,
Feb 8, 2017, 4:53:10 AM2/8/17
to 高橋誠二, golang-nuts, dja...@gmail.com


On Wed, Feb 8, 2017, 4:32 PM 高橋誠二 <tima...@gmail.com> wrote:
yes, I know but other languages support it as default, isn't it?

*some* languages apparently do. But then again maybe you could ask the opposite question to those languages. Why did these languages you refer to choose to implement a Printlnf? In said language, is it not trivial to simply add the newline character to your format string? Did it warrant it's own builtin function?


2017年2月8日水曜日 12時31分00秒 UTC+9 dja...@gmail.com:


On Wednesday, February 8, 2017 at 3:58:55 AM UTC+2, 高橋誠二 wrote:
fmt package have no *lnf method, but in other langs,
sometimes it implements Printlnf.
Is there any reason?

fmt.Printlnf(f,...) = fmt.Printf(f+"\n", ...)
Djadala 

--

Konstantin Khomoutov

unread,
Feb 8, 2017, 5:24:33 AM2/8/17
to Justin Israel, 高橋誠二, golang-nuts, dja...@gmail.com
On Wed, 08 Feb 2017 09:52:49 +0000
Justin Israel <justin...@gmail.com> wrote:

> > fmt package have no *lnf method, but in other langs,
> > sometimes it implements Printlnf.
> > Is there any reason?
> > yes, I know but other languages support it as default, isn't it?
> *some* languages apparently do. But then again maybe you could ask the
> opposite question to those languages. Why did these languages you
> refer to choose to implement a Printlnf? In said language, is it not
> trivial to simply add the newline character to your format string?
> Did it warrant it's own builtin function?

Another question to ask is whether that imaginary fmt.Printlnf()
should output a platform-default EOL sequence or plain LF in all cases.

An interesting point is that implementing it either way is wrong ;-)
Reply all
Reply to author
Forward
0 new messages