On 2011-08-24, at 05:10 , Reinhold Kainhofer wrote:

> Am Wednesday, 24. August 2011, 10:49:30 schrieben Sie:
>> Hi  Graham, Carl,
>> 
>> On Tue 23 Aug 2011 19:34:37 BST, Carl Sorensen wrote:
>>> On 8/23/11 12:21 PM, "ianhuli...@gmail.com" <ianhuli...@gmail.com> wrote:
>>>> Maybe we should have some GOP rules for C++ about this?
>>>> "Only have multiple exit points from routines if you absolutely have to.
> 
> There is really not much difference in
> 
> if (some_condition)
>  return;
> 
> and
> 
> if (!some_condition)
>  {
>    ....
>  }
> 
> Except that if you have many conditions the indentation in the second example 
> will be terrible and make the whole thing hard to read.


There can be a run-time performance difference between branching or not 
branching.  For the times you actually care, if you're not going to use 
compiler-specific features to mark conditions as likely or unlikely, you should 
test the likely case first so that there is no branching most of the time.

> You can mess up equally with both.

Some of us have. :-)

You can also write functions that are equally difficult to read with both.  The 
readability depends more on what is inside your ellipsis above than whether the 
unexpected condition is handled before or after it.
-- 
Dan


_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to