So, to print or not to print?

Era Scarecrow via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 26 13:06:48 PDT 2016


On Tuesday, 26 April 2016 at 12:38:06 UTC, Jonathan M Davis wrote:
> On Tuesday, April 26, 2016 08:50:23 ixid via Digitalmars-d 
> wrote:
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.

  We could always use C++ streams! They are perfectly clear what 
they're doing, right?

  stdout << a << " " << b << " " << c << endl;

  Seriously, a formatting line may only be confusing at first, but 
it's something you need to learn at some point. I don't ever want 
to rely on something as ugly as streams. C had printf; which was 
print, with an f! and that was good enough for everything! (I 
feel like I'm quoting Garfield now)

  Not that long ago when I was getting into D, I used printf more, 
then when I memorized writeln I used it a lot more. It's really 
not that bad. More people should sit down and read the damn 
documentation (mind you I've read about half of it, and I need to 
start over now since it's been so long).


More information about the Digitalmars-d mailing list