<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Fri, Dec 9, 2016 at 7:36 AM Zachary Turner <<a href="mailto:zturner@google.com">zturner@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><div dir="ltr" style="font-size:small" class="gmail_msg"><br class="m_7905197640900016269inbox-inbox-inbox-inbox-Apple-interchange-newline gmail_msg">On Fri, Dec 9, 2016 at 4:00 AM Jason Molenda via Phabricator <<a href="mailto:reviews@reviews.llvm.org" class="gmail_msg" target="_blank">reviews@reviews.llvm.org</a>> wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="font-size:small;margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br class="gmail_msg">I'm not thrilled with the formatv reinvention of format specification.  The printf formatters are a bizarre little invention, but it's a bizarre invention that we've all worked with for decades and everyone who works in C knows well.  The formatv format specification may be superior, but I don't want to see innovation here, I want clarity with the linga franca that every C programmer knows.  I think the barrier to adopting something non-standard is very high.<br class="gmail_msg"></blockquote></div><div dir="ltr" class="gmail_msg"><div style="font-size:small" class="gmail_msg">While everyone knows it well, somehow it's still complicated enough that its usage is riddled with errors.  I can't even count the number of bugs I've fixed related to incorrect usage of format specifiers.  <br class="gmail_msg"> </div></div><div dir="ltr" class="gmail_msg"><blockquote class="gmail_quote gmail_msg" style="font-size:small;margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br class="gmail_msg">The formatv format specification string seems to explicitly mention the ordering of the arguments, like llvm::formatv("{0} {1} {2}", first, second, third).  I'm guessing this allows you to print the arguments in different order than they appear?  Like  llvm::formatv("{0} {2} {2} {1}", first, second, third)?  What's the benefit of this vrs. the uncertainty of which arguments are used in different parts of the string (short of counting them out by hand)?  If I have a formatv format specification like "{0} {1} {2} {3} {4}" and I want to insert an argument between 2 and 3, I need to renumber 3 and 4 now?  Or do I do "{0} {1} {2} {5} {3} {4}" and throw my argument on to the end?<br class="gmail_msg"></blockquote></div><div dir="ltr" class="gmail_msg"><div style="font-size:small" class="gmail_msg">Either / or would be fine.  BTW, this is not the primary advantage of having the arguments be numbered.  The primary advantage is that it allows you to print the same argument multiple times without computing it.   formatv("{0} {0} {0}", 7);   will print "7 7 7".</div></div></blockquote><div> </div><div>I guess I should elaborate.  The *real* primary advantage is simply not specifying the format specifier at all.  When you have to match the format specifier to the type of the argument you've already lost the battle, because you've introduced a source of programmer error.  And not just a hypothetical source either, considering the number of bugs I've fixed in incorrect usage of format specifiers.</div></div></div>