News for hackers. Stuff that matters.
Re:Tidy First? by WesolyKubeczek on Thursday January 11, 2024 @09:06AM (#38952310)
Well, aren't early returns in guard clauses "recovery from abnormality"?

You could flex some language lawyering to define "abnormality"...

Re:Tidy First? by aulin on Thursday January 11, 2024 @10:25AM (#38953460)
I believe that's exactly it. An exception to the single return rule to allow for guard clauses. Wording is maybe a little too obscure though.
Re:Tidy First? by eesmith on Thursday January 11, 2024 @11:25AM (#38954382)
I don't know.

Here is the only relevant example I found:

  p = X_MALLOC(sizeof(*p) * NUM);
  if (p == NULL) {
    return (MEM_NOTHING);
  }
  ...
  X_FREE(p);
  return (OK);
It's clearly abnormal.

Something like a:

   if (get_size(obj) == 0) {
       return empty_case;
   }
   ... do more complicated code here ...
   return result;
does not feel "abnormal".