[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Python or Perl for a Debian maintainance project?



On Thu, Feb 19, 2004 at 10:42:56AM +0800, Isaac To wrote:
> For me, if "goto" is used in a disciplined way, one shouldn't be afraid to
> use them, especially if it simplify your code.

I developped a technique for application-level programming:

LOCK* lock = get_lock ();
int ok = (lock != NULL);
if (ok)
  ok = foo ();
if (ok)
  ok = bar ();
if (LOCK != NULL)
  release (lock);
return ok;

Instead of:

LOCK* lock = get_lock ();
if (lock == NULL)
  goto FAIL;
if (!foo ())
  goto FAIL;
if (!bar ())
  goto FAIL;
return 1;
FAIL:
  if (NULL != foo)
    release (lock);
  return 0;

I prefer the former: the gotos are if (ok)'s instead.
I just like the "not jumping" aspect: as the routine grows in complexity 
(as it shouldn't, but it does), the depth-one, linear flow is easier for 
me to grok.



Reply to: