Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #20796

Re: Redundant return()

From nick_keighley_nospam@hotmail.com
Newsgroups comp.lang.c
Subject Re: Redundant return()
Date 2012-05-15 03:26 -0700
Organization http://groups.google.com
Message-ID <20221261.1910.1337077574383.JavaMail.geo-discussion-forums@vbih30> (permalink)
References (2 earlier) <jorci2$5pa$1@speranza.aioe.org> <27375124.1151.1337067212163.JavaMail.geo-discussion-forums@vbip22> <return-20120515095002@ram.dialup.fu-berlin.de> <7259216.24.1337076222367.JavaMail.geo-discussion-forums@vbk4> <multiple-returns-20120515121735@ram.dialup.fu-berlin.de>

Show all headers | View raw


On Tuesday, May 15, 2012 11:21:19 AM UTC+1, Stefan Ram wrote:
> nick_keighley_nospam@hotmail.com writes:
> >On Tuesday, May 15, 2012 8:51:40 AM UTC+1, Stefan Ram wrote:
> >>nick_keighley writes:

like I said in a bit of my post you snipped. This is a style thing. Some people like to jump through hoops to give single-entry-single-exit properties to their code. Some don't. I simply object to you stating it as if it were some sort of Programming Law.

> >>>/* complex processing */
> >why? My code was clear and easy to understand.
> 
>   Assume, you had complex code:
> 
>   ...
>     ... return ...
>       ... 
>     ... return ...
>       ... return ...
>     ...
>   ...
>     ... return ...
>       ...
>     ... return ...
>       ... return ...
>     ...

I don't usually write code that is as complicated as that.

>   The many returns hinder extract-function refactoring,

haven't noticed a problem.

>   because, when you want to extract the first half of this
>   into a separate function, the returns now jump to the end of
>   that new function, which usually is not what they are
>   supposed to do, so one has to do a more complex and
>   error-prone rewriting during this refactor.
> 
>   When a block has a single entry and exit, the 
>   extract-function refactor is usually easy.
> 
>   This could be a reason that complex code such as 
>   above is not refactored, so that it will be harder
>   to maintain.
> 
> >>. The real reason for an early return as in
> >"real"? Why is this any more "real" than any other reason?
> 
>   It is the only excuse that I accept for the use of multiple
>   returns in a function.

whatever

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Redundant return() pembed2012 <once@was.enough.invalid> - 2012-05-12 21:41 +0000
  Re: Redundant return() pembed2012 <once@was.enough.invalid> - 2012-05-12 21:56 +0000
    Re: Redundant return() Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-05-12 17:07 -0600
  Re: Redundant return() James Kuyper <jameskuyper@verizon.net> - 2012-05-12 18:46 -0400
    Re: Redundant return() Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-05-12 20:10 -0400
      Re: Redundant return() James Kuyper <jameskuyper@verizon.net> - 2012-05-12 21:29 -0400
  Re: Redundant return() Barry Schwarz <schwarzb@dqel.com> - 2012-05-12 15:49 -0700
    Re: Redundant return() pembed2012 <once@was.enough.invalid> - 2012-05-14 16:40 +0000
      Re: Redundant return() Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-05-14 17:57 +0100
      Re: Redundant return() nick_keighley_nospam@hotmail.com - 2012-05-15 00:33 -0700
        Re: Redundant return() nick_keighley_nospam@hotmail.com - 2012-05-15 03:03 -0700
          Re: Redundant return() nick_keighley_nospam@hotmail.com - 2012-05-15 03:26 -0700
          Re: Redundant return() James Kuyper <jameskuyper@verizon.net> - 2012-05-15 08:51 -0400
        Re: Redundant return() "BartC" <bc@freeuk.com> - 2012-05-15 12:20 +0100
          Re: Redundant return() Ian Collins <ian-news@hotmail.com> - 2012-05-16 07:59 +1200
            Re: Redundant return() Kaz Kylheku <kaz@kylheku.com> - 2012-05-15 20:08 +0000
              Re: Redundant return() Ian Collins <ian-news@hotmail.com> - 2012-05-16 08:18 +1200
                Re: Redundant return() Lanarcam <lanarcam1@yahoo.fr> - 2012-05-15 22:48 +0200
                Re: Redundant return() Ian Collins <ian-news@hotmail.com> - 2012-05-16 09:56 +1200
            Re: Redundant return() "BartC" <bc@freeuk.com> - 2012-05-15 22:59 +0100
              Re: Redundant return() Ian Collins <ian-news@hotmail.com> - 2012-05-16 10:16 +1200
                Re: Redundant return() "BartC" <bc@freeuk.com> - 2012-05-16 09:29 +0100
        Re: Redundant return() Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-05-15 07:51 -0400
        Re: Redundant return() James Kuyper <jameskuyper@verizon.net> - 2012-05-15 08:47 -0400
          Re: Redundant return() Ian Collins <ian-news@hotmail.com> - 2012-05-16 08:01 +1200
          Re: Redundant return() "BartC" <bc@freeuk.com> - 2012-05-15 22:58 +0100
            Re: Redundant return() Ian Collins <ian-news@hotmail.com> - 2012-05-16 10:24 +1200
              Re: Redundant return() James Kuyper <jameskuyper@verizon.net> - 2012-05-15 18:39 -0400
              Re: Redundant return() nick_keighley_nospam@hotmail.com - 2012-05-16 02:45 -0700
  Re: Redundant return() Noob <root@127.0.0.1> - 2012-05-16 13:34 +0200

csiph-web