🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3613

Re: Wishful thinking: return-parameter

#3613
From: Zefram
Date: Wed, 02 Aug 1995 08:02
47 lines
1824 bytes
 <halasz@caip.rutgers.edu> wrote:
>No, we are _obliged_ to uze a "goto"ish means for quitting the
>function,

If the current return keyword is banned, there will be a great deal
more use of actual gotos, just to get to the end of a function in order
to return.  I can see code currently like

int fn()
{
 int ret;
 if(some_error_condition()) return -1;
 /* ... */
 return ret;
}

turning into

int fn() ret
{
 if(some_error_condition()) { ret=-1; goto end; }
 /* ... */
 end:
}

which is much more disgusting.  It rather resembles the Pascal code I
produce (when I have no choice of language) when I get just too pissed
off with tortuous nested ifs and weird this_loop_done flags.  Of
course, in Pascal it's made all the more fun by the fact that, strictly
speaking, labels are required to be purely numeric...

In FORTRAN, there *is* a RETURN statement, even though it uses
return-variable syntax.  Emulating this would leave the return keyword
in place, with its current semantics, only changing the syntax used to
specify the return value.  I don't see any significant advantage in
doing

int fn() ret
{
 if(some_error_condition()) { ret=-1; return; }
 /* ... */
 return;
}

in place of the current syntax (my first example above).

-zefram
Technical Details
Message-ID: <1995Aug2.080237.17479@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> <DCL2LC.GBK@proteon.com> <3vjjl6$7nm@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: <1995Aug2.080237.17479@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> <DCL2LC.GBK@proteon.com> <3vjjl6$7nm@caip.rutgers.edu>
Date: Wed, 2 Aug 1995 08:02:37 GMT