Quote:
Originally Posted by Gambet
Yeah, and it would confuse the heck out of someone that didn't know what %s, %d, and/or %+3d meant.
|
Well, if they understand the rest of my script, chances are they are smart enough to look up what format() does. Also, anyone who has ever read the first chapter of a tutorial on C and probably half of those who read tutorials about C++ know how printf works. Other than that while obviously it is a good thing to not intentionally obfuscate scripts, dumbing scripts down other than for learning purposes is not really something I can get behind.
Quote:
|
At least when you write it out the 'longer' way, one can pretty much assume what that line of code is supposed to do based on the fact that it's fully written out and people would be able to use context clues to put two and two together.
|
"Hey, look, a bunch of text with apparently magical symbols that do seem to occur in grammatically interesting places, and a bunch of variables afterwards, and the function is called format, I wonder whether these could be placeholders used to format these variables into the text, and if I am not sure I can still check the documentation!" is close enough for me.
Also if I was not totally ignorant of people who do not bother to learn English yet play on an English server, I would agree with Stefan about the localisation issue because translating lots of string fragments with no obvious logical connection and without the ability to reorder the inserted variables to conform to the target language's grammar gets old really fast.
Apart from that, the whole integer formatting part of format is probably way more powerful than equivalent string concatenation magic. And did anyone ever benchmark format applications against equivalent string concatenations?