<div dir="ltr"><div><span style="font-size:13px">I was one of the people that commented on that review, so you already know my opinion, but sicne it hasn't been stated in any kind of official thread and some people might not click the link I will restate it here.</span><div style="font-size:13px"><br></div><div style="font-size:13px">I feel very strongly that true means success.  I think *every* existing occurrence of true on error should be fixed (not necessarily immediately or with high priority).  I would push back on any attempt to add a new function that returns true on failure.  </div><div style="font-size:13px"><br></div><div style="font-size:13px">implicit integer-to-boolean conversions are bad, and so despite the fact that people often write stuff like if (!strcmp(x, y)) we should not be basing decisions about good usage on the fact that bad usage is common.  </div></div><div style="font-size:13px"><br></div><div style="font-size:13px">Functions that return bools are frequently named with verbs.  It's beyond confusing to have code such as:</div><div style="font-size:13px"><br></div><div style="font-size:13px">if (withdrawMoney(Account, Amount))</div><div style="font-size:13px">  reportAnError();</div><div style="font-size:13px"><br></div><div style="">Types like llvm::Error are an exception and while it can still be confusing, some of this confusion is alleviated by the fact that you have to actually assign the return value to something or else your program will fail with an assertion.  So, for example, if the above function returned an llvm::Error, you'd assert that the error was unhandled, and you'd have to re-write it:<br></div><div style=""><br></div><div style="">if (auto Err = withdrawMoney(Account, Amount))</div><div style="">  report(Err);</div><div style=""><br></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Sep 17, 2018 at 10:57 AM Nico Weber <<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</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"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi,<div><br></div><div>in <a href="https://reviews.llvm.org/D52143" target="_blank">https://reviews.llvm.org/D52143</a> there's some uncertainty if LLVM code prefers</div><div><br></div><div>  if (!Function())</div><div>    // Call to function failed, deal with it</div><div><br></div><div>or</div><div><br></div><div><div>  if (Function())</div><div>    // Call to function failed, deal with it</div></div><div><br></div><div>(Note that this is about functions returning bool, not int.)<br></div><div><br></div><div>Folks on that review feel that returning true on success is probably what we want, but it's not documented anywhere and we do have both forms in the codebase.</div><div><br>True on success seems more common:</div><div><a href="http://llvm-cs.pcc.me.uk/?q=true+on+success" target="_blank">http://llvm-cs.pcc.me.uk/?q=true+on+success</a><br></div><div><a href="http://llvm-cs.pcc.me.uk/?q=true+on+error" target="_blank">http://llvm-cs.pcc.me.uk/?q=true+on+error</a><br></div><div><br></div><div>Does anyone have a pointer to previous on-list discussion on this? If not, this thread could be the place where we sort this out once and for all :-)</div><div><br></div><div>Apologies for the bike-sheddy topic.</div></div></div></div></div></div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><br></div><div>Nico</div></div></div></div></div></div></blockquote></div></div>