So, to print or not to print?

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 26 05:38:06 PDT 2016


On Tuesday, April 26, 2016 08:50:23 ixid via Digitalmars-d wrote:
> On Tuesday, 26 April 2016 at 03:13:22 UTC, Jonathan M Davis wrote:
> > On Tuesday, April 26, 2016 01:44:07 Jack Stouffer via
> >
> > Digitalmars-d wrote:
> >> On Monday, 25 April 2016 at 19:35:04 UTC, Andrei Alexandrescu
> >>
> >> wrote:
> >> > https://github.com/dlang/phobos/pull/3971
> >>
> >> I really don't see the utility of the function over writefln
> >> being great enough to warrant inclusion. I'd vote not to
> >> include it.
> >
> > I concur. IMHO, it doesn't add enough value to be worth it, and
> > given that it adds yet another printing function, it'll
> > increase confusion with newcomers.
> >
> > - Jonathan M Davis
>
> Please find an example of a newcomer who would be confused by
> print. This is an objectionable argument because none of the
> people making it are newcomers, you're using an entirely
> theoretical newcomer as your argument, and seem to think
> 'print(a, b, c);' is going to confuse people more than
> 'writefln("%s %s %s", a, b, c);' which is ridiculous.

Honestly, I think that writefln is way clearer than print. Certainly, if
you're familiar with printf, it's pretty obvious what writefln does with the
possible confusion over whether it prints a newline or not (and the ln in
the name is there to tell you that), whereas it's not at all obvious what
print is going to do without looking at the docs.

Regardless, even having two printing functions requires that programmers
learn what the differences between them are. Each one added to the mix is
yet another one whose slight differences has to be distinguished from the
others. And we already have 4 of them - write, writef, writeln, and
writefln, which is arguably too many. But at least they have a sensible
naming scheme that helps distinguish them. print, on the other hand, has
nothing in common with them and no indicators in its name how it differs
from the others.

Honestly, I see no value whatsoever in print. writefln already does the same
job and in a clearer manner.

- Jonathan M Davis



More information about the Digitalmars-d mailing list