So, to print or not to print?

Meta via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 26 08:46:48 PDT 2016


On Monday, 25 April 2016 at 19:35:04 UTC, Andrei Alexandrescu 
wrote:
> https://github.com/dlang/phobos/pull/3971
>
> Walter and I were talking this morning that there should be a 
> high barrier of entry for one-liners in Phobos. The "print" 
> function is technically a one-liner (i.e. writefln with the 
> appropriate format string). On the other hand, it may be 
> convivial enough to warrant inclusion, and saves us from 
> embarrassing things such as producing meaningless output when 
> numbers are printed together.
>
> There's been a bit of churn in the PR comments regarding the 
> utility of "print", and discussion diverged into other 
> functions such as "dump" etc. Keeping it on topic: any strong 
> cons and pros regarding the function? I want to either merge or 
> close the PR and move on.
>
>
> Thanks,
>
> Andrei

Python users are only a subset of new users coming to D, and as 
far as I know it is the only big language where such a `print` 
primitive exists with the semantics of putting spaces between 
each item printed. Ruby also has `print` but it does not put 
spaces between arguments; it adds a newline after each argument. 
So which behaviour should we copy?

None of the other big languages, C, C++, Javascript, Java, C#, 
Scala, Groovy, et al., have a `print` function that matches the 
semantics of Python's print (nor Ruby's). Why add yet another IO 
function that will only help very inexperienced beginners coming 
from a single (popular, granted) language? I'm all for making the 
D experience easy for beginners, but this is not a low-hanging 
fruit. It's just rotten.


More information about the Digitalmars-d mailing list