What are everyones thoughts on hints (H2077) for value assigned to the result of a function that is never used. I get these often from initializing result to something before I ever write any code.

What are everyones thoughts on hints (H2077) for value assigned to the result of a function that is never used.  I get these often from initializing result to something before I ever write any code.

Does anyone do something similar, do you ignore the hint or remove the intialization?

Comments

  1. Simon Stuart Yes, I realize we're not talking grammar rules, but the comment was half in jest. Since the optimization rules aren't defined to us, the area is grey, at best.

    ReplyDelete
  2. Personally I prefer guard clauses over initializing the result variable.

    if SomeCondition then
      Exit(false) //nil, emptystr, whatever

    ReplyDelete
  3. Kenneth Cochran You might want to consider the TArgument class in the Delphi Spring Framework if you like guard clauses.

    ReplyDelete

Post a Comment