writeln and ~

Ignacious via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jan 14 09:42:05 PST 2017


string concatenation is weird.

We can do stuff like

writeln(x);

where x is, say a struct and it prints fine

but when we do

writeln(x ~ " ok");

it fails and requires us to convert x!

Why can't string concatenation automatically try to convert the 
arguments? Is there any reason this is bad behavior?

How bout then having writeln parse the arguments as a string(take 
an alias or something first) and then automatically convert them?

Seems like there is no real excuse to add such obfuscation...

Obviously I can roll my own but that is not an acceptable answer.





More information about the Digitalmars-d-learn mailing list