lilypond-devel
[Top][All Lists]
Advanced

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

Re: Fix uninitialized variables when Source_file::get_counts returns ear


From: David Kastrup
Subject: Re: Fix uninitialized variables when Source_file::get_counts returns early due to !contains (pos_str0) (issue 4940047)
Date: Wed, 24 Aug 2011 11:04:09 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Ian Hulin <address@hidden> writes:

> I'm not asking for a grand re-write on this, but for single-exit to be
> the preferred style for new code and patches where this would not
> provoke changes on a GCR (Grand Code Re-write) scale.

I disagree.  Structured exits decrease the level of nesting and
contortion and make code more straightforward to follow.

if (!precondition)
  {
     return 0;
  }
// Do the real work, 200+ lines of code, 5 levels of nesting
return zappa (whatever);

is much much more cleaner to follow than

zappadap result;

if (precondition)
  {
     // Do the real work, 200+ lines of code, 5 levels of nesting
     result = zappa (whatever);
  }
else
  {
     result = 0;
  }
return result;


Get the trivial cases out of the way, completely, first.  That way, you
don't need to keep yellow tabs on braces to track even the trivial code.
Write and read code like a man!  Juggling a dozen open ends at once is
the special skillset of childraisers, not programmers.  And if you do
both at once, you'll be glad you don't need to track large contexts even
for the trivial tasks, when you have a spare minute for programming.

-- 
David Kastrup




reply via email to

[Prev in Thread] Current Thread [Next in Thread]