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


Groups > comp.lang.c > #41668 > unrolled thread

Is goto Still Considered Harmful?

Started byLynn McGuire <lmc@winsim.com>
First post2014-03-12 11:02 -0500
Last post2014-03-29 05:56 -0700
Articles 9 on this page of 149 — 45 participants

Back to article view | Back to comp.lang.c


Contents

  Is goto Still Considered Harmful? Lynn McGuire <lmc@winsim.com> - 2014-03-12 11:02 -0500
    Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-03-12 12:17 -0400
    Re: Is goto Still Considered Harmful? nospam@see.signature (Richard Maine) - 2014-03-12 09:20 -0700
      Re: Is goto Still Considered Harmful? Lynn McGuire <lmc@winsim.com> - 2014-03-18 16:30 -0500
        Re: Is goto Still Considered Harmful? Geoff <geoff@invalid.invalid> - 2014-03-18 17:36 -0700
          Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-03-19 07:34 -0400
            Re: Is goto Still Considered Harmful? "BartC" <bc@freeuk.com> - 2014-03-19 12:08 +0000
              Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-03-19 10:07 -0400
                Re: Is goto Still Considered Harmful? Richard <rgrdev_@gmail.com> - 2014-03-19 17:05 +0100
              Re: Is goto Still Considered Harmful? Lynn McGuire <lmc@winsim.com> - 2014-03-19 12:27 -0500
        Re: Is goto Still Considered Harmful? "Terence" <tbwright@bigpond.net.au> - 2014-03-19 20:35 +1100
          Re: Is goto Still Considered Harmful? Lynn McGuire <lmc@winsim.com> - 2014-03-19 12:26 -0500
    Re: Is goto Still Considered Harmful? Kaz Kylheku <kaz@kylheku.com> - 2014-03-12 16:47 +0000
      Re: Is goto Still Considered Harmful? Jos Bergervoet <jos.bergervoet@xs4all.nl> - 2014-03-12 19:07 +0100
        Re: Is goto Still Considered Harmful? Andrew Cooper <root@127.0.0.1> - 2014-03-12 23:36 +0000
          Re: Is goto Still Considered Harmful? Kaz Kylheku <kaz@kylheku.com> - 2014-03-13 00:23 +0000
            Re: Is goto Still Considered Harmful? Andrew Cooper <root@127.0.0.1> - 2014-03-13 01:18 +0000
              Re: Is goto Still Considered Harmful? Kaz Kylheku <kaz@kylheku.com> - 2014-03-13 02:08 +0000
                Re: Is goto Still Considered Harmful? Andrew Cooper <root@127.0.0.1> - 2014-03-13 02:21 +0000
                Re: Is goto Still Considered Harmful? David Brown <david.brown@hesbynett.no> - 2014-03-13 11:17 +0100
          Re: Is goto Still Considered Harmful? Melzzzzz <mel@zzzzz.invalid> - 2014-03-13 01:53 +0100
        Re: Is goto Still Considered Harmful? Les Cargill <lcargill99@comcast.com> - 2014-03-13 01:46 -0500
      Re: Is goto Still Considered Harmful? Johannes Bauer <dfnsonfsduifb@gmx.de> - 2014-03-13 10:56 +0100
      Re: Is goto Still Considered Harmful? "Nasser M. Abbasi" <nma@12000.org> - 2014-03-16 08:18 -0500
        Re: Is goto Still Considered Harmful? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-03-16 15:18 +0000
          Re: Is goto Still Considered Harmful? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-03-20 11:36 -0700
    Re: Is goto Still Considered Harmful? "BartC" <bc@freeuk.com> - 2014-03-12 18:50 +0000
      Re: Is goto Still Considered Harmful? <william@wilbur.25thandClement.com> - 2014-03-12 12:49 -0700
      Re: Is goto Still Considered Harmful? "Qolin" <noone@nowhere.com> - 2014-03-12 21:54 +0000
        Re: Is goto Still Considered Harmful? Lynn McGuire <lmc@winsim.com> - 2014-03-12 16:57 -0500
        Re: Is goto Still Considered Harmful? Keith Thompson <kst-u@mib.org> - 2014-03-12 15:36 -0700
          Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-03-12 19:02 -0400
            Re: Is goto Still Considered Harmful? Keith Thompson <kst-u@mib.org> - 2014-03-12 16:58 -0700
              Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-03-12 20:09 -0400
          Re: Is goto Still Considered Harmful? Keith Thompson <kst-u@mib.org> - 2014-03-12 16:44 -0700
        Re: Is goto Still Considered Harmful? Robert Wessel <robertwessel2@yahoo.com> - 2014-03-12 23:40 -0500
          Re: Is goto Still Considered Harmful? David Brown <david.brown@hesbynett.no> - 2014-03-13 11:25 +0100
          Re: Is goto Still Considered Harmful? Thomas Jahns <jahns@idontlikespam.dkrz.de> - 2014-03-14 11:24 +0100
            Re: Is goto Still Considered Harmful? Robert Wessel <robertwessel2@yahoo.com> - 2014-03-14 23:32 -0500
            Re: Is goto Still Considered Harmful? Dr Nick <nospam-4@temporary-address.org.uk> - 2014-03-15 13:43 +0000
              Re: Is goto Still Considered Harmful? David Brown <david.brown@hesbynett.no> - 2014-03-15 16:28 +0100
                Re: Is goto Still Considered Harmful? Dr Nick <nospam-4@temporary-address.org.uk> - 2014-03-15 16:01 +0000
                  Re: Is goto Still Considered Harmful? David Brown <david.brown@hesbynett.no> - 2014-03-17 08:51 +0100
      Re: Is goto Still Considered Harmful? David Brown <david.brown@hesbynett.no> - 2014-03-13 11:22 +0100
    Re: Is goto Still Considered Harmful? ralph <nt_consulting@yahoo.com> - 2014-03-12 15:34 -0500
    Re: Is goto Still Considered Harmful? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2014-03-12 17:48 -0700
    Re: Is goto Still Considered Harmful? jt@toerring.de (Jens Thoms Toerring) - 2014-03-13 01:06 +0000
      Re: Is goto Still Considered Harmful? wilson <winslole@udayton.edu> - 2014-03-13 03:59 -0400
        Re: Is goto Still Considered Harmful? wilson <winslole@udayton.edu> - 2014-03-13 05:02 -0400
          Re: Is goto Still Considered Harmful? Richard Damon <Richard@Damon-Family.org> - 2014-03-13 08:42 -0400
            Re: Is goto Still Considered Harmful? gazelle@shell.xmission.com (Kenny McCormack) - 2014-03-13 14:45 +0000
      Re: Is goto Still Considered Harmful? Louis Krupp <lkrupp@nospam.pssw.com.invalid> - 2014-03-13 07:42 -0600
        Re: Is goto Still Considered Harmful? Richard <rgrdev_@gmail.com> - 2014-03-13 14:56 +0100
    Re: Is goto Still Considered Harmful? Wolfgang Kilian <kilian@invalid.com> - 2014-03-13 09:10 +0100
    Re: Is goto Still Considered Harmful? mark.bluemel@gmail.com - 2014-03-13 08:02 -0700
    Re: Is goto Still Considered Harmful? Thomas Koenig <tkoenig@netcologne.de> - 2014-03-13 21:09 +0000
      Re: Is goto Still Considered Harmful? "Qolin" <noone@nowhere.com> - 2014-03-13 21:24 +0000
        Re: Is goto Still Considered Harmful? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-03-13 22:36 +0000
          Re: Is goto Still Considered Harmful? Robert Wessel <robertwessel2@yahoo.com> - 2014-03-13 23:02 -0500
            Re: Is goto Still Considered Harmful? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-03-14 04:07 +0000
              Re: Is goto Still Considered Harmful? Robert Wessel <robertwessel2@yahoo.com> - 2014-03-13 23:56 -0500
            Re: Is goto Still Considered Harmful? helbig@astro.multiCLOTHESvax.de (Phillip Helbig---undress to reply) - 2014-03-14 09:17 +0000
      Re: Is goto Still Considered Harmful? Kaz Kylheku <kaz@kylheku.com> - 2014-03-13 22:42 +0000
        Re: Is goto Still Considered Harmful? "James Van Buskirk" <not_valid@comcast.net> - 2014-03-13 17:13 -0600
          Re: Is goto Still Considered Harmful? Keith Thompson <kst-u@mib.org> - 2014-03-13 16:46 -0700
            Re: Is goto Still Considered Harmful? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-03-14 01:17 +0000
              Re: Is goto Still Considered Harmful? Robert Wessel <robertwessel2@yahoo.com> - 2014-03-13 23:04 -0500
                Re: Is goto Still Considered Harmful? David Brown <david.brown@hesbynett.no> - 2014-03-14 10:41 +0100
                  Re: Is goto Still Considered Harmful? Kaz Kylheku <kaz@kylheku.com> - 2014-03-14 09:55 +0000
                    Re: Is goto Still Considered Harmful? David Brown <david.brown@hesbynett.no> - 2014-03-14 13:16 +0100
                    Re: Is goto Still Considered Harmful? Seebs <usenet-nospam@seebs.net> - 2014-03-18 21:08 +0000
                      Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-03-18 17:41 -0400
          Re: Is goto Still Considered Harmful? Kaz Kylheku <kaz@kylheku.com> - 2014-03-14 00:45 +0000
            Re: Is goto Still Considered Harmful? "James Van Buskirk" <not_valid@comcast.net> - 2014-03-13 21:40 -0600
              Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-03-14 01:02 -0400
                Re: Is goto Still Considered Harmful? "James Van Buskirk" <not_valid@comcast.net> - 2014-03-14 10:36 -0600
                  Re: Is goto Still Considered Harmful? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-03-14 17:30 +0000
                  Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-03-14 13:51 -0400
                    Re: Is goto Still Considered Harmful? Keith Thompson <kst-u@mib.org> - 2014-03-14 13:12 -0700
                  Re: Is goto Still Considered Harmful? Tim Rentsch <txr@alumni.caltech.edu> - 2014-03-29 06:46 -0700
              Re: Is goto Still Considered Harmful? Kaz Kylheku <kaz@kylheku.com> - 2014-03-14 05:29 +0000
                Re: Is goto Still Considered Harmful? "James Van Buskirk" <not_valid@comcast.net> - 2014-03-14 10:47 -0600
                  Re: Is goto Still Considered Harmful? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-03-14 17:43 +0000
                  Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-03-14 13:52 -0400
              Re: Is goto Still Considered Harmful? Stephen Sprunk <stephen@sprunk.org> - 2014-03-16 17:15 -0500
                Re: Is goto Still Considered Harmful? Keith Thompson <kst-u@mib.org> - 2014-03-16 16:04 -0700
      Re: Is goto Still Considered Harmful? Kaz Kylheku <kaz@kylheku.com> - 2014-03-14 05:11 +0000
        Re: Is goto Still Considered Harmful? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-03-14 06:00 +0000
    Re: Is goto Still Considered Harmful? "Terence" <tbwright@bigpond.net.au> - 2014-03-14 08:32 +1100
      Re: Is goto Still Considered Harmful? Richard Damon <Richard@Damon-Family.org> - 2014-03-14 23:10 -0400
    Re: Is goto Still Considered Harmful? Rosario193 <Rosario@invalid.invalid> - 2014-03-14 02:18 +0100
      Re: Is goto Still Considered Harmful? Lynn McGuire <lmc@winsim.com> - 2014-03-18 16:14 -0500
    Re: Is goto Still Considered Harmful? John Bode <jfbode1029@gmail.com> - 2014-03-24 07:52 -0700
      Re: Is goto Still Considered Harmful? Ken Brody <kenbrody@spamcop.net> - 2014-03-24 11:20 -0400
        Re: Is goto Still Considered Harmful? "BartC" <bc@freeuk.com> - 2014-03-24 17:08 +0000
        Re: Is goto Still Considered Harmful? Ken Brody <kenbrody@spamcop.net> - 2014-03-25 14:06 -0400
          Re: Is goto Still Considered Harmful? Lowell Gilbert <lgusenet@be-well.ilk.org> - 2014-03-26 13:31 -0400
      Re: Is goto Still Considered Harmful? gazelle@shell.xmission.com (Kenny McCormack) - 2014-03-24 16:31 +0000
      Re: Is goto Still Considered Harmful? "BartC" <bc@freeuk.com> - 2014-03-24 16:46 +0000
        Re: Is goto Still Considered Harmful? John Bode <jfbode1029@gmail.com> - 2014-03-24 16:10 -0700
          Re: Is goto Still Considered Harmful? Keith Thompson <kst-u@mib.org> - 2014-03-24 17:19 -0700
            Re: Is goto Still Considered Harmful? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-03-25 02:56 -0700
            Re: Is goto Still Considered Harmful? Keith Thompson <kst-u@mib.org> - 2014-03-25 07:34 -0700
              Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-03-25 10:57 -0400
                Re: Is goto Still Considered Harmful? gazelle@shell.xmission.com (Kenny McCormack) - 2014-03-25 16:09 +0000
                Re: Is goto Still Considered Harmful? Kaz Kylheku <kaz@kylheku.com> - 2014-03-25 16:14 +0000
                  Re: Is goto Still Considered Harmful? Ian Collins <ian-news@hotmail.com> - 2014-03-26 08:06 +1300
                  Re: Is goto Still Considered Harmful? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-03-25 12:49 -0700
                  Re: Is goto Still Considered Harmful? Stephen Sprunk <stephen@sprunk.org> - 2014-03-31 14:05 -0500
                    Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-03-31 15:20 -0400
                      Re: Is goto Still Considered Harmful? Stephen Sprunk <stephen@sprunk.org> - 2014-04-04 14:56 -0500
                        Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-04-04 17:11 -0400
                          Re: Is goto Still Considered Harmful? Ian Collins <ian-news@hotmail.com> - 2014-04-05 12:03 +1300
                          Re: Is goto Still Considered Harmful? ralph <nt_consulting@yahoo.com> - 2014-04-05 00:17 -0500
                            Re: Is goto Still Considered Harmful? Ian Collins <ian-news@hotmail.com> - 2014-04-05 20:14 +1300
                          Re: Is goto Still Considered Harmful? Stephen Sprunk <stephen@sprunk.org> - 2014-04-09 14:30 -0500
                            Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-04-09 16:37 -0400
                              Re: Is goto Still Considered Harmful? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-09 14:01 -0700
                        Re: Is goto Still Considered Harmful? Richard <rgrdev_@gmail.com> - 2014-04-05 15:21 +0100
                    Re: Is goto Still Considered Harmful? Ian Collins <ian-news@hotmail.com> - 2014-04-01 11:04 +1300
                      Re: Is goto Still Considered Harmful? Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2014-04-01 02:45 +0300
                        Re: Is goto Still Considered Harmful? Ian Collins <ian-news@hotmail.com> - 2014-04-01 13:03 +1300
                          Re: Is goto Still Considered Harmful? Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2014-05-22 12:01 +0300
                            Re: Is goto Still Considered Harmful? Ian Collins <ian-news@hotmail.com> - 2014-05-22 21:22 +1200
                        Re: Is goto Still Considered Harmful? Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2014-05-22 11:53 +0300
                Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-03-31 12:10 -0400
                  Re: Is goto Still Considered Harmful? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-03-31 10:39 -0700
                    Re: Is goto Still Considered Harmful? Stephen Sprunk <stephen@sprunk.org> - 2014-03-31 13:42 -0500
                      Re: Is goto Still Considered Harmful? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-03-31 15:16 -0700
                        Re: Is goto Still Considered Harmful? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-01 00:24 -0700
                          Re: Is goto Still Considered Harmful? Richard Damon <Richard@Damon-Family.org> - 2014-04-01 08:26 -0400
                            Re: Is goto Still Considered Harmful? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-01 06:50 -0700
                              Re: Are setters Stil Considered Harmful? (was: Is goto Still Considered Harmful?) Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-02 10:49 -0700
              Re: Is goto Still Considered Harmful? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-03-25 19:30 +0000
                Re: Is goto Still Considered Harmful? Ken Brody <kenbrody@spamcop.net> - 2014-03-27 09:33 -0400
              Re: Is goto Still Considered Harmful? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-03-25 19:37 +0000
          Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-03-25 00:30 -0400
          Re: Is goto Still Considered Harmful? John Bode <jfbode1029@gmail.com> - 2014-03-27 11:47 -0700
            Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-03-27 20:39 -0400
              Re: Is goto Still Considered Harmful? gazelle@shell.xmission.com (Kenny McCormack) - 2014-03-28 01:40 +0000
            Re: Is goto Still Considered Harmful? Richard <rgrdev_@gmail.com> - 2014-03-28 10:09 +0100
              Re: Is goto Still Considered Harmful? gazelle@shell.xmission.com (Kenny McCormack) - 2014-03-28 09:48 +0000
              Re: Is goto Still Considered Harmful? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-03-28 03:24 -0700
                Re: Is goto Still Considered Harmful? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-03-28 18:52 +0000
                Re: Is goto Still Considered Harmful? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-03-30 02:45 -0700
      Re: Is goto Still Considered Harmful? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-03-24 12:53 -0700
      Re: Is goto Still Considered Harmful? John Bode <jfbode1029@gmail.com> - 2014-03-24 15:02 -0700
        Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-03-24 19:11 -0400
    Re: Is goto Still Considered Harmful? Tim Rentsch <txr@alumni.caltech.edu> - 2014-03-29 05:56 -0700

Page 8 of 8 — ← Prev page 1 2 3 4 5 6 7 [8]


#42248

FromRichard <rgrdev_@gmail.com>
Date2014-03-28 10:09 +0100
Message-ID<87siq2u1t8.fsf@gmail.com>
In reply to#42223
John Bode <jfbode1029@gmail.com> writes:

> On Monday, March 24, 2014 6:32:40 PM UTC-5, Stefan Ram wrote:
>> John Bode <jfbode1029@gmail.com> writes:
>> >Is that example completely contrived?  I wish I could say it was.  It was 
>> >inspired by real code I've had to review in the past (except that "foo" was
>> >several *thousand* lines long and there were 12 or 13 more labels with
>> >gotos branching all over the goddamned place).  
>> 
>>   As others and I have said before: One might as well claim that in this
>>   case, the problem is not the use of gotos, but the huge size of functions.
>> 
>
> Large functions are not necessarily *hard* to debug, if you can be certain
> of the control flow.  I'm arguing that adding gotos to the mix makes a bad
> situation worse.  

It could be argued that in many cases its easier - especially with
multiple return statements..... When you read a book do you limit the
chapters to half a page?

People who break up code into otherwise unused functions need to
reevaluate. It breaks the read flow, causes the debugger to jump around
losing reading context.

Like all things it needs to be done sensibly.

Outlawing anything more than 16 lines or banning more than one return
statement are the action of small minded types with no bigger picture.

[toc] | [prev] | [next] | [standalone]


#42250

Fromgazelle@shell.xmission.com (Kenny McCormack)
Date2014-03-28 09:48 +0000
Message-ID<lh3gh0$cjp$2@news.xmission.com>
In reply to#42248
In article <87siq2u1t8.fsf@gmail.com>, Richard  <rgrdev_@gmail.com> wrote:
...
>Outlawing anything more than 16 lines or banning more than one return
>statement are the action of small minded types with no bigger picture.

Otherwise known as "CLC regs".

Hence, this sub-thread topic is right up their alley.

-- 
But the Bush apologists hope that you won't remember all that. And they
also have a theory, which I've been hearing more and more - namely,
that President Obama, though not yet in office or even elected, caused the
2008 slump. You see, people were worried in advance about his future
policies, and that's what caused the economy to tank. Seriously.

    (Paul Krugman - Addicted to Bush)

[toc] | [prev] | [next] | [standalone]


#42252

FromMalcolm McLean <malcolm.mclean5@btinternet.com>
Date2014-03-28 03:24 -0700
Message-ID<acd17e7d-cfa8-4176-9f5d-0e677e402697@googlegroups.com>
In reply to#42248
On Friday, March 28, 2014 9:09:39 AM UTC, Richard wrote:
> 
> It could be argued that in many cases its easier - especially with
> multiple return statements..... When you read a book do you limit the
> chapters to half a page?
> 
If a paragraph goes over half a page I'd break it up. It does depend what 
you're writing - fiction needs continuous flow, so the chapters are about
2,000 words, with these days maybe the odd blank line to break up sections.
Technical writing has far more short sections with headings.
> 
> Outlawing anything more than 16 lines or banning more than one return
> statement are the action of small minded types with no bigger picture.
>
Early C reserved a keyword, I think it was called "entry" to indicate that
a function could be called from more than one point. It was never implemented,
and the consensus is that it was a bad idea.
Personally I use a variable called "answer" as the return for most functions,
and the function end "return answer". I try to have only one return, but
I'll occasionally return early on aborts (e.g. a statistical function called
with N = 0), and I won't fuss about a terminal if(conditon) return true else 
return false. I won't write it as return (condition), which is harder to
read.
 

[toc] | [prev] | [next] | [standalone]


#42259

Fromglen herrmannsfeldt <gah@ugcs.caltech.edu>
Date2014-03-28 18:52 +0000
Message-ID<lh4gdu$vv4$1@speranza.aioe.org>
In reply to#42252
Malcolm McLean <malcolm.mclean5@btinternet.com> wrote:

(snip)

> Early C reserved a keyword, I think it was called "entry" to 
> indicate that a function could be called from more than one point. 
> It was never implemented, and the consensus is that it was a bad 
> idea. 

Fortran and PL/I have ENTRY, and sometimes it is convenient and
useful. For example, SIN and COS, written in assembly, are commonly
one routine that does argment reduction differently, but then goes
into the rest of the computation in common.  

I was once debugging with gdb a gfortran program with ENTRY, and
was surprised at what it did. gfortran uses the same back end as 
gcc, which it seems can't generate ENTRY. The result is one function
for each entry point, which then calls another with the appropriate
combination of arguments.

I believe it is depricated in Fortran, probably not in PL/I.

-- glen

[toc] | [prev] | [next] | [standalone]


#42350

FromMalcolm McLean <malcolm.mclean5@btinternet.com>
Date2014-03-30 02:45 -0700
Message-ID<e1589d7d-f423-4d2a-a793-23aa76d54a0b@googlegroups.com>
In reply to#42252
On Friday, March 28, 2014 4:34:21 PM UTC, Stefan Ram wrote:
> Malcolm McLean <malcolm.mclean5@btinternet.com> writes:
> 
> >I'll occasionally return early on aborts (e.g. a statistical function called
> >with N = 0),
> 
>   When you write a function »double average( int const N ...«,
>   what value do you return on an abort?
>
It just depends. There's a case for nan or 0, sometimes I use DBL_MAX.
You might or might not want an assert in there too. Whilst you've still got
to return something, on many environments asserts are left in on release
builds, so it's largely academic.

If you know the context the function is going to be called from, that tells
you what to do. For example I recently wrote an average function for a 
palette chooser. You could conceivably get an empty list (e.g. if user chooses
a 256 colour palette from 8x8 image), so it's correct to quietly return black
for unused cells. So in that case, putting return 0 is the easy if slightly
hacky way of dealing with it. 

[toc] | [prev] | [next] | [standalone]


#42109

FromMalcolm McLean <malcolm.mclean5@btinternet.com>
Date2014-03-24 12:53 -0700
Message-ID<4b52ea69-d591-479a-a72a-b19402b8a6fe@googlegroups.com>
In reply to#42092
On Monday, March 24, 2014 2:52:55 PM UTC, John Bode wrote:
> 
> Gotos (or, more specifically, labeled statements) make code harder to 
> debug and review by inspection; that's my main issue with them.  
> 
> My rules for using gotos:
> 
> 1.  Branch forward only;
> 2.  Don't bypass the entry of a standard control structure;
> 3a.  Don't use goto in place of a standard control structure;
> 3b.  Don't use goto if break or continue will work just as well;
> 4.  Don't overlap gotos;
> 
Generally I use gotos only for jumping to an error_exit label. Which boils
down to memory allocation failure (for a pure function), or IO error for
an IO routine.
But there was an exception recently. A Newton_Raphson root finder. Almost
always you guess a root and it converges on a near answer. But just occasionally it can get stuck in an alternating cycle. So you need to
set the guess to a random other value, and restart it.
Whilst you could write this in non-goto control structures, you still
need a flag, and it obscures the fact that restarting is pretty unlikely to
happen. So I decided a backwards goto was better. 

[toc] | [prev] | [next] | [standalone]


#42113

FromJohn Bode <jfbode1029@gmail.com>
Date2014-03-24 15:02 -0700
Message-ID<07a59737-4b15-4ec5-b9bb-815b12df1c41@googlegroups.com>
In reply to#42092
On Monday, March 24, 2014 10:19:46 AM UTC-5, Stefan Ram wrote:
> John Bode <jfbode1029@gmail.com> writes:
> >i = 5;
> >label: printf( "%d\n", i );
> >What value gets printed for i?  *When* does it get printed?  Until I 
> >account for every instance of "goto label;" in the function, I can't
> >know that.  
> 
>   What about this: void f( int const i ){ printf( "%d\n", i ); }?
> 

The function f is now extremely easy to review and inspect; I know 
that the value specified as the argument will be printed once per 
call.  There's a clearly defined entry and exit.  No matter how the 
function is called, I have a clear idea of how the function itself
behaves by simple inspection.  

>   I can use the same wording now:
> 
>       What value gets printed for i?  *When* does it get
>       printed?  Until I account for every instance of a
>       call of that function f, I can't know that.
>

You've missed whole the point of my example.  By, like, a *lot*.

>   Moreover, values in programming are /runtime/ values. That 
>   means that in general they cannot be deduced by a static
>   code analysis anyways.
> 
>   And does it always matter to know all this?
>

When you're tasked with reverse engineering a monolithic, spaghettified 
monstrosity to figure out how to rewrite it so that it's faster, more 
stable, and more maintainable, *yes*.

I've been in that movie more than once.  I've been given a pile of code
that sort-of-but-doesn't-really work with no documentation or requirements
and told to "figure out what it does and make it better".  And every time I 
see a labeled statement in those situations my heart sinks a bit, because 
now the job is that much harder.  IME there's a strong correlation between 
the presence of a labeled statement and poor programming practice; functions 
that are hundreds (sometimes thousands) of lines long that do twenty different
things, gotos branching hither and yon, inconsistent naming conventions, etc.  

At least if I'm reviewing new code, I can kick it back to the author and say
"nope, try again, I'm not approving this crap."  But if it's code where the
original author has long since skedaddled and the money won't let you just
rewrite the whole thing from the keel up like you should?  Then yeah, this 
matters.  

> 
> >Obviously, if you need to exit a nested loop, a break won't
> >be sufficient (it will only break out of the innermost loop).  
> 
>   The whole thread suffers from talking vaguely about code
>   instead of looking at a fixed and complete and specific
>   code and a specification of what it is suppossed to do.
> 

The OP was as general as possible - are gotos considered harmful?  Not, 
are gotos considered harmful *in this situation*, or, are gotos considered
harmful *in this specific code*, but, are gotos considered harmful, *period*?

There's *no way* to answer a question like that except in generalities.  

>   When talking vaguely in that matter everyone can say
>   everything and can never be proven false.

[toc] | [prev] | [next] | [standalone]


#42115

FromJames Kuyper <jameskuyper@verizon.net>
Date2014-03-24 19:11 -0400
Message-ID<5330BB96.4010905@verizon.net>
In reply to#42113
On 03/24/2014 06:02 PM, John Bode wrote:
> On Monday, March 24, 2014 10:19:46 AM UTC-5, Stefan Ram wrote:
...
>>   The whole thread suffers from talking vaguely about code
>>   instead of looking at a fixed and complete and specific
>>   code and a specification of what it is suppossed to do.
>>
> 
> The OP was as general as possible - are gotos considered harmful?  Not, 
> are gotos considered harmful *in this situation*, or, are gotos considered
> harmful *in this specific code*, but, are gotos considered harmful, *period*?
> 
> There's *no way* to answer a question like that except in generalities.

It is, however, entirely appropriate to bring up specific cases in an
attempt to prove that having a general rule is inappropriate.

[toc] | [prev] | [next] | [standalone]


#42281

FromTim Rentsch <txr@alumni.caltech.edu>
Date2014-03-29 05:56 -0700
Message-ID<kfn1txlmacv.fsf@x-alumni2.alumni.caltech.edu>
In reply to#41668
Lynn McGuire <lmc@winsim.com> writes:

> Is goto Still Considered Harmful?
>
> http://www.drdobbs.com/architecture-and-design/is-goto-still-considered-harmful/240166595

gotos are like weeds.  A garden may have a few weeds scattered
here and there yet still be a fairly nice garden.  But when a
garden has weeds all over the place it starts to look pretty
ratty, even if it's a rather nice garden otherwise.  And of
course the very nicest gardens have no weeds at all.

Dijkstra's point is not about gotos but about programmers, viz.,
programmers who feel no compunction against using goto freely
tend to write lousy code.  And this is borne out IME:  even among
developers who are okay with using goto on occasion, the good
ones still have an aversion to using it generally and look for an
alternate formulation before resorting to goto.

[toc] | [prev] | [standalone]


Page 8 of 8 — ← Prev page 1 2 3 4 5 6 7 [8]

Back to top | Article view | comp.lang.c


csiph-web