🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3738

Re: Wishful thinking: return-parameter

#3738
From: Zefram
Date: Wed, 16 Aug 1995 04:01
34 lines
1983 bytes
<halasz@caip.rutgers.edu> wrote:
>In article <1995Aug2.080237.17479@dcs.warwick.ac.uk>, A.Main@dcs.warwick.ac.uk (Zefram) writes
>+ ....
>+ int fn() ret
>+ {
>+  if(some_error_condition()) { ret=-1; goto end; }
>+  /* ... */
>+  end:
>+ }
>+ 
>+ which is much more disgusting....
>
>which is much better, for there openlie is "goto", not one hidden
>under "return".

One might as well insist on rewriting all for loops using while, on the
grounds that the for is `hiding' a while.  In fact, for and while are
just hiding a few ifs and gotos!  We obviously must ban the use of
while, in order to make the gotos explicit.  And the structured ifs are
just hiding gotos too -- let's make goto the only statement that it's
legal to put in a conditional!  And ban else!  In summary, your
proposal naturally leads us to totally abandon structured programming,
in order to avoid implicit gotos.

By contrast, return -- which has relatively unstructured semantics --
won't always perform a jump.  In void functions it almost never will,
and on platforms where arguments and return values are passed in
registers very few functions will require more than one machine-code
instruction in the way of cleanup code.  The chances are, on such an
implementation, the code you prefer -- with a goto instead of a return
-- would be optimised to an actual return.  Coding it that way makes
much more sense.

-zefram
Technical Details
Message-ID: <1995Aug16.040124.24562@dcs.warwick.ac.uk>
Path: arc1-ca.pugleaf.net!news.dcs.warwick.ac.uk!not-for-mail
References: <3ver2u$8bk@caip.rutgers.edu> <3vg8l8$5sd@myst.plaza.ds.adp.com> <1995Aug2.080237.17479@dcs.warwick.ac.uk> <3vpffj$qnc@caip.rutgers.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!news.dcs.warwick.ac.uk!not-for-mail
From: A.Main@dcs.warwick.ac.uk (Zefram)
Subject: Re: Wishful thinking: return-parameter
X-Nntp-Posting-Host: stone
Message-ID: <1995Aug16.040124.24562@dcs.warwick.ac.uk>
Sender: news@dcs.warwick.ac.uk (Network News)
Organization: Department of Computer Science, Warwick University, England
References: <3ver2u$8bk@caip.rutgers.edu> <3vg8l8$5sd@myst.plaza.ds.adp.com> <1995Aug2.080237.17479@dcs.warwick.ac.uk> <3vpffj$qnc@caip.rutgers.edu>
Date: Wed, 16 Aug 1995 04:01:24 GMT